src/Entity/Order/Order.php line 17

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Entity\Order;
  4. use App\Entity\User\AdminUser;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Sylius\Component\Core\Model\Order as BaseOrder;
  7. use Sylius\Component\Order\Model\OrderItemInterface;
  8. use ThreeBRS\SyliusPaymentFeePlugin\Model\AdjustmentInterface;
  9. /**
  10.  * @ORM\Entity
  11.  * @ORM\Table(name="sylius_order")
  12.  */
  13. class Order extends BaseOrder implements OrderInterface
  14. {
  15.     /**
  16.      * @ORM\Column(type="text", nullable=true)
  17.      */
  18.     private $notes2;
  19.     /**
  20.      * @ORM\ManyToOne(targetEntity="App\Entity\User\AdminUser", inversedBy="operators")
  21.      * @ORM\JoinColumn(name="operator_id", referencedColumnName="id", nullable=true, onDelete="CASCADE")
  22.      */
  23.     private $operator;
  24.     /**
  25.      * @ORM\Column(type="text", nullable=true)
  26.      */
  27.     private $heardAboutUs null;
  28. //    /**
  29. //     * @ORM\Column(type="text", nullable=true)
  30. //     */
  31. //    private $heardAboutUsOthers = null;
  32.     public function getHeardAboutUs(): ?string
  33.     {
  34.         return $this->heardAboutUs;
  35.     }
  36.     public function setHeardAboutUs(?string $heardAboutUs): void
  37.     {
  38.         $this->heardAboutUs $heardAboutUs;
  39.     }
  40. //    public function getHeardAboutUsOthers(): ?string
  41. //    {
  42. //        return $this->heardAboutUsOthers;
  43. //    }
  44. //
  45. //    public function setHeardAboutUsOthers(?string $heardAboutUsOthers): void
  46. //    {
  47. //        $this->heardAboutUsOthers = $heardAboutUsOthers;
  48. //    }
  49.     public function getNotes2(): ?string
  50.     {
  51.         return $this->notes2;
  52.     }
  53.     public function setNotes2(?string $notes2): void
  54.     {
  55.         $this->notes2 $notes2;
  56.     }
  57.     public function getOperator(): ?AdminUser
  58.     {
  59.         return $this->operator;
  60.     }
  61.     public function setOperator(?AdminUser $operator): void
  62.     {
  63.         $this->operator $operator;
  64.     }
  65.     /**
  66.      * Returns payment fee together with taxes (decreased by payment discount - zatial nemame).
  67.      */
  68.     public function getPaymentFeeTotal(): int
  69.     {
  70.         $paymentTotal $this->getAdjustmentsTotal(AdjustmentInterface::PAYMENT_ADJUSTMENT );
  71.         // $shippingTotal += $this->getAdjustmentsTotal(AdjustmentInterface::ORDER_PAYMENT_PROMOTION_ADJUSTMENT);
  72.         $paymentTotal += $this->getAdjustmentsTotal(AdjustmentInterface::TAX_ADJUSTMENT);
  73.         return $paymentTotal;
  74.     }
  75.     public function removeItem(OrderItemInterface $item): void
  76.     {
  77.         if ($this->hasItem($item)) {
  78.             $this->items->removeElement($item);
  79.             foreach ($this->items as $object) {
  80.                 if ($object->isGift()) {
  81.                     $this->items->removeElement($object);
  82.                 }
  83.             }
  84.             $this->itemsTotal -= $item->getTotal();
  85.             $this->recalculateTotal();
  86.             $item->setOrder(null);
  87.         }
  88.     }
  89.     public function recalculateItemsTotal(): void
  90.     {
  91.         $this->itemsTotal 0;
  92.         foreach ($this->items as $item) {
  93.             $this->itemsTotal += $item->getTotal();
  94.         }
  95.         $this->recalculateTotal();
  96.     }
  97. }