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

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