vendor/shopware/core/Checkout/Order/OrderEntity.php line 27

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Shopware\Core\Checkout\Order;
  3. use Shopware\Core\Checkout\Cart\Price\Struct\CalculatedPrice;
  4. use Shopware\Core\Checkout\Cart\Price\Struct\CartPrice;
  5. use Shopware\Core\Checkout\Document\DocumentCollection;
  6. use Shopware\Core\Checkout\Order\Aggregate\OrderAddress\OrderAddressCollection;
  7. use Shopware\Core\Checkout\Order\Aggregate\OrderAddress\OrderAddressEntity;
  8. use Shopware\Core\Checkout\Order\Aggregate\OrderCustomer\OrderCustomerEntity;
  9. use Shopware\Core\Checkout\Order\Aggregate\OrderDelivery\OrderDeliveryCollection;
  10. use Shopware\Core\Checkout\Order\Aggregate\OrderLineItem\OrderLineItemCollection;
  11. use Shopware\Core\Checkout\Order\Aggregate\OrderTransaction\OrderTransactionCollection;
  12. use Shopware\Core\Framework\DataAbstractionLayer\Entity;
  13. use Shopware\Core\Framework\DataAbstractionLayer\EntityCustomFieldsTrait;
  14. use Shopware\Core\Framework\DataAbstractionLayer\EntityIdTrait;
  15. use Shopware\Core\Framework\DataAbstractionLayer\Pricing\CashRoundingConfig;
  16. use Shopware\Core\Framework\Log\Package;
  17. use Shopware\Core\System\Currency\CurrencyEntity;
  18. use Shopware\Core\System\Language\LanguageEntity;
  19. use Shopware\Core\System\SalesChannel\SalesChannelEntity;
  20. use Shopware\Core\System\StateMachine\Aggregation\StateMachineState\StateMachineStateEntity;
  21. use Shopware\Core\System\Tag\TagCollection;
  22. use Shopware\Core\System\User\UserEntity;
  23. #[Package('customer-order')]
  24. class OrderEntity extends Entity
  25. {
  26.     use EntityIdTrait;
  27.     use EntityCustomFieldsTrait;
  28.     /**
  29.      * @var string
  30.      */
  31.     protected $orderNumber;
  32.     /**
  33.      * @var string
  34.      */
  35.     protected $currencyId;
  36.     /**
  37.      * @var float
  38.      */
  39.     protected $currencyFactor;
  40.     /**
  41.      * @var string
  42.      */
  43.     protected $salesChannelId;
  44.     /**
  45.      * @var string
  46.      */
  47.     protected $billingAddressId;
  48.     /**
  49.      * @var \DateTimeInterface
  50.      */
  51.     protected $orderDateTime;
  52.     /**
  53.      * @var \DateTimeInterface
  54.      */
  55.     protected $orderDate;
  56.     /**
  57.      * @var CartPrice
  58.      */
  59.     protected $price;
  60.     /**
  61.      * @var float
  62.      */
  63.     protected $amountTotal;
  64.     /**
  65.      * @var float|null
  66.      */
  67.     protected $amountNet;
  68.     /**
  69.      * @var float
  70.      */
  71.     protected $positionPrice;
  72.     /**
  73.      * @var string
  74.      */
  75.     protected $taxStatus;
  76.     /**
  77.      * @var CalculatedPrice
  78.      */
  79.     protected $shippingCosts;
  80.     /**
  81.      * @var float
  82.      */
  83.     protected $shippingTotal;
  84.     /**
  85.      * @var OrderCustomerEntity|null
  86.      */
  87.     protected $orderCustomer;
  88.     /**
  89.      * @var CurrencyEntity|null
  90.      */
  91.     protected $currency;
  92.     /**
  93.      * @var string
  94.      */
  95.     protected $languageId;
  96.     /**
  97.      * @var LanguageEntity
  98.      */
  99.     protected $language;
  100.     /**
  101.      * @var SalesChannelEntity|null
  102.      */
  103.     protected $salesChannel;
  104.     /**
  105.      * @var OrderAddressCollection|null
  106.      */
  107.     protected $addresses;
  108.     /**
  109.      * @var OrderAddressEntity|null
  110.      */
  111.     protected $billingAddress;
  112.     /**
  113.      * @var OrderDeliveryCollection|null
  114.      */
  115.     protected $deliveries;
  116.     /**
  117.      * @var OrderLineItemCollection|null
  118.      */
  119.     protected $lineItems;
  120.     /**
  121.      * @var OrderTransactionCollection|null
  122.      */
  123.     protected $transactions;
  124.     /**
  125.      * @var string|null
  126.      */
  127.     protected $deepLinkCode;
  128.     /**
  129.      * @var int
  130.      */
  131.     protected $autoIncrement;
  132.     /**
  133.      * @var StateMachineStateEntity|null
  134.      */
  135.     protected $stateMachineState;
  136.     /**
  137.      * @var string
  138.      */
  139.     protected $stateId;
  140.     /**
  141.      * @var DocumentCollection|null
  142.      */
  143.     protected $documents;
  144.     /**
  145.      * @var TagCollection|null
  146.      */
  147.     protected $tags;
  148.     /**
  149.      * @var string|null
  150.      */
  151.     protected $affiliateCode;
  152.     /**
  153.      * @var string|null
  154.      */
  155.     protected $campaignCode;
  156.     /**
  157.      * @var string|null
  158.      */
  159.     protected $customerComment;
  160.     /**
  161.      * @var array<string>|null
  162.      */
  163.     protected $ruleIds = [];
  164.     /**
  165.      * @var string|null
  166.      */
  167.     protected $createdById;
  168.     /**
  169.      * @var UserEntity|null
  170.      */
  171.     protected $createdBy;
  172.     /**
  173.      * @var string|null
  174.      */
  175.     protected $updatedById;
  176.     /**
  177.      * @var UserEntity|null
  178.      */
  179.     protected $updatedBy;
  180.     /**
  181.      * @var CashRoundingConfig|null
  182.      */
  183.     protected $itemRounding;
  184.     /**
  185.      * @var CashRoundingConfig|null
  186.      */
  187.     protected $totalRounding;
  188.     public function getCurrencyId(): string
  189.     {
  190.         return $this->currencyId;
  191.     }
  192.     public function setCurrencyId(string $currencyId): void
  193.     {
  194.         $this->currencyId $currencyId;
  195.     }
  196.     public function getCurrencyFactor(): float
  197.     {
  198.         return $this->currencyFactor;
  199.     }
  200.     public function setCurrencyFactor(float $currencyFactor): void
  201.     {
  202.         $this->currencyFactor $currencyFactor;
  203.     }
  204.     public function getSalesChannelId(): string
  205.     {
  206.         return $this->salesChannelId;
  207.     }
  208.     public function setSalesChannelId(string $salesChannelId): void
  209.     {
  210.         $this->salesChannelId $salesChannelId;
  211.     }
  212.     public function getBillingAddressId(): string
  213.     {
  214.         return $this->billingAddressId;
  215.     }
  216.     public function setBillingAddressId(string $billingAddressId): void
  217.     {
  218.         $this->billingAddressId $billingAddressId;
  219.     }
  220.     public function getOrderDateTime(): \DateTimeInterface
  221.     {
  222.         return $this->orderDateTime;
  223.     }
  224.     public function setOrderDateTime(\DateTimeInterface $orderDateTime): void
  225.     {
  226.         $this->orderDateTime $orderDateTime;
  227.     }
  228.     public function getOrderDate(): \DateTimeInterface
  229.     {
  230.         return $this->orderDate;
  231.     }
  232.     public function setOrderDate(\DateTimeInterface $orderDate): void
  233.     {
  234.         $this->orderDate $orderDate;
  235.     }
  236.     public function getPrice(): CartPrice
  237.     {
  238.         return $this->price;
  239.     }
  240.     public function setPrice(CartPrice $price): void
  241.     {
  242.         $this->price $price;
  243.     }
  244.     public function getAmountTotal(): float
  245.     {
  246.         return $this->amountTotal;
  247.     }
  248.     public function getAmountNet(): float
  249.     {
  250.         return $this->amountNet;
  251.     }
  252.     public function getPositionPrice(): float
  253.     {
  254.         return $this->positionPrice;
  255.     }
  256.     public function getTaxStatus(): string
  257.     {
  258.         return $this->taxStatus;
  259.     }
  260.     public function getShippingCosts(): CalculatedPrice
  261.     {
  262.         return $this->shippingCosts;
  263.     }
  264.     public function setShippingCosts(CalculatedPrice $shippingCosts): void
  265.     {
  266.         $this->shippingCosts $shippingCosts;
  267.     }
  268.     public function getShippingTotal(): float
  269.     {
  270.         return $this->shippingTotal;
  271.     }
  272.     public function getOrderCustomer(): ?OrderCustomerEntity
  273.     {
  274.         return $this->orderCustomer;
  275.     }
  276.     public function setOrderCustomer(OrderCustomerEntity $orderCustomer): void
  277.     {
  278.         $this->orderCustomer $orderCustomer;
  279.     }
  280.     public function getCurrency(): ?CurrencyEntity
  281.     {
  282.         return $this->currency;
  283.     }
  284.     public function setCurrency(CurrencyEntity $currency): void
  285.     {
  286.         $this->currency $currency;
  287.     }
  288.     public function getLanguageId(): string
  289.     {
  290.         return $this->languageId;
  291.     }
  292.     public function setLanguageId(string $languageId): void
  293.     {
  294.         $this->languageId $languageId;
  295.     }
  296.     public function getLanguage(): LanguageEntity
  297.     {
  298.         return $this->language;
  299.     }
  300.     public function setLanguage(LanguageEntity $language): void
  301.     {
  302.         $this->language $language;
  303.     }
  304.     public function getSalesChannel(): ?SalesChannelEntity
  305.     {
  306.         return $this->salesChannel;
  307.     }
  308.     public function setSalesChannel(SalesChannelEntity $salesChannel): void
  309.     {
  310.         $this->salesChannel $salesChannel;
  311.     }
  312.     public function getAddresses(): ?OrderAddressCollection
  313.     {
  314.         return $this->addresses;
  315.     }
  316.     public function setAddresses(OrderAddressCollection $addresses): void
  317.     {
  318.         $this->addresses $addresses;
  319.     }
  320.     public function getDeliveries(): ?OrderDeliveryCollection
  321.     {
  322.         return $this->deliveries;
  323.     }
  324.     public function setDeliveries(OrderDeliveryCollection $deliveries): void
  325.     {
  326.         $this->deliveries $deliveries;
  327.     }
  328.     public function getLineItems(): ?OrderLineItemCollection
  329.     {
  330.         return $this->lineItems;
  331.     }
  332.     public function setLineItems(OrderLineItemCollection $lineItems): void
  333.     {
  334.         $this->lineItems $lineItems;
  335.     }
  336.     public function getTransactions(): ?OrderTransactionCollection
  337.     {
  338.         return $this->transactions;
  339.     }
  340.     public function setTransactions(OrderTransactionCollection $transactions): void
  341.     {
  342.         $this->transactions $transactions;
  343.     }
  344.     public function getDeepLinkCode(): ?string
  345.     {
  346.         return $this->deepLinkCode;
  347.     }
  348.     public function setDeepLinkCode(string $deepLinkCode): void
  349.     {
  350.         $this->deepLinkCode $deepLinkCode;
  351.     }
  352.     public function getAutoIncrement(): int
  353.     {
  354.         return $this->autoIncrement;
  355.     }
  356.     public function setAutoIncrement(int $autoIncrement): void
  357.     {
  358.         $this->autoIncrement $autoIncrement;
  359.     }
  360.     public function getStateMachineState(): ?StateMachineStateEntity
  361.     {
  362.         return $this->stateMachineState;
  363.     }
  364.     public function setStateMachineState(StateMachineStateEntity $stateMachineState): void
  365.     {
  366.         $this->stateMachineState $stateMachineState;
  367.     }
  368.     public function getStateId(): string
  369.     {
  370.         return $this->stateId;
  371.     }
  372.     public function setStateId(string $stateId): void
  373.     {
  374.         $this->stateId $stateId;
  375.     }
  376.     public function setAmountTotal(float $amountTotal): void
  377.     {
  378.         $this->amountTotal $amountTotal;
  379.     }
  380.     public function setAmountNet(float $amountNet): void
  381.     {
  382.         $this->amountNet $amountNet;
  383.     }
  384.     public function setPositionPrice(float $positionPrice): void
  385.     {
  386.         $this->positionPrice $positionPrice;
  387.     }
  388.     public function setTaxStatus(string $taxStatus): void
  389.     {
  390.         $this->taxStatus $taxStatus;
  391.     }
  392.     public function setShippingTotal(float $shippingTotal): void
  393.     {
  394.         $this->shippingTotal $shippingTotal;
  395.     }
  396.     public function getDocuments(): ?DocumentCollection
  397.     {
  398.         return $this->documents;
  399.     }
  400.     public function setDocuments(DocumentCollection $documents): void
  401.     {
  402.         $this->documents $documents;
  403.     }
  404.     public function getOrderNumber(): ?string
  405.     {
  406.         return $this->orderNumber;
  407.     }
  408.     public function setOrderNumber(string $orderNumber): void
  409.     {
  410.         $this->orderNumber $orderNumber;
  411.     }
  412.     public function getTags(): ?TagCollection
  413.     {
  414.         return $this->tags;
  415.     }
  416.     public function setTags(TagCollection $tags): void
  417.     {
  418.         $this->tags $tags;
  419.     }
  420.     public function getNestedLineItems(): ?OrderLineItemCollection
  421.     {
  422.         $lineItems $this->getLineItems();
  423.         if (!$lineItems) {
  424.             return null;
  425.         }
  426.         /** @var OrderLineItemCollection $roots */
  427.         $roots $lineItems->filterByProperty('parentId'null);
  428.         $roots->sortByPosition();
  429.         $this->addChildren($lineItems$roots);
  430.         return $roots;
  431.     }
  432.     public function getAffiliateCode(): ?string
  433.     {
  434.         return $this->affiliateCode;
  435.     }
  436.     public function setAffiliateCode(?string $affiliateCode): void
  437.     {
  438.         $this->affiliateCode $affiliateCode;
  439.     }
  440.     public function getCampaignCode(): ?string
  441.     {
  442.         return $this->campaignCode;
  443.     }
  444.     public function setCampaignCode(?string $campaignCode): void
  445.     {
  446.         $this->campaignCode $campaignCode;
  447.     }
  448.     public function getCustomerComment(): ?string
  449.     {
  450.         return $this->customerComment;
  451.     }
  452.     public function setCustomerComment(?string $customerComment): void
  453.     {
  454.         $this->customerComment $customerComment;
  455.     }
  456.     public function getRuleIds(): ?array
  457.     {
  458.         return $this->ruleIds;
  459.     }
  460.     /**
  461.      * @param array<string>|null $ruleIds
  462.      */
  463.     public function setRuleIds(?array $ruleIds): void
  464.     {
  465.         $this->ruleIds $ruleIds;
  466.     }
  467.     public function getBillingAddress(): ?OrderAddressEntity
  468.     {
  469.         return $this->billingAddress;
  470.     }
  471.     public function setBillingAddress(OrderAddressEntity $billingAddress): void
  472.     {
  473.         $this->billingAddress $billingAddress;
  474.     }
  475.     public function getCreatedById(): ?string
  476.     {
  477.         return $this->createdById;
  478.     }
  479.     public function setCreatedById(string $createdById): void
  480.     {
  481.         $this->createdById $createdById;
  482.     }
  483.     public function getCreatedBy(): ?UserEntity
  484.     {
  485.         return $this->createdBy;
  486.     }
  487.     public function setCreatedBy(UserEntity $createdBy): void
  488.     {
  489.         $this->createdBy $createdBy;
  490.     }
  491.     public function getUpdatedById(): ?string
  492.     {
  493.         return $this->updatedById;
  494.     }
  495.     public function setUpdatedById(string $updatedById): void
  496.     {
  497.         $this->updatedById $updatedById;
  498.     }
  499.     public function getUpdatedBy(): ?UserEntity
  500.     {
  501.         return $this->updatedBy;
  502.     }
  503.     public function setUpdatedBy(UserEntity $updatedBy): void
  504.     {
  505.         $this->updatedBy $updatedBy;
  506.     }
  507.     public function getItemRounding(): ?CashRoundingConfig
  508.     {
  509.         return $this->itemRounding;
  510.     }
  511.     public function setItemRounding(?CashRoundingConfig $itemRounding): void
  512.     {
  513.         $this->itemRounding $itemRounding;
  514.     }
  515.     public function getTotalRounding(): ?CashRoundingConfig
  516.     {
  517.         return $this->totalRounding;
  518.     }
  519.     public function setTotalRounding(?CashRoundingConfig $totalRounding): void
  520.     {
  521.         $this->totalRounding $totalRounding;
  522.     }
  523.     private function addChildren(OrderLineItemCollection $lineItemsOrderLineItemCollection $parents): void
  524.     {
  525.         foreach ($parents as $parent) {
  526.             /** @var OrderLineItemCollection $children */
  527.             $children $lineItems->filterByProperty('parentId'$parent->getId());
  528.             $children->sortByPosition();
  529.             $parent->setChildren($children);
  530.             $this->addChildren($lineItems$children);
  531.         }
  532.     }
  533. }