src/Entity/Gos/OrderProductVariant.php line 18

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Gos;
  3. use App\Entity\Gos\Uniqskills\Course;
  4. use App\Entity\Gos\Uniqskills\OrderCycle;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. /**
  9.  * OrderProduct
  10.  *
  11.  * @ORM\Table()
  12.  * @ORM\Entity(repositoryClass="App\Repository\OrderProductVariantRepository")
  13.  * @ORM\HasLifecycleCallbacks
  14.  */
  15. class OrderProductVariant
  16. {
  17.     /**
  18.      * @var int
  19.      *
  20.      * @ORM\Column(name="id", type="integer")
  21.      * @ORM\Id
  22.      * @ORM\GeneratedValue(strategy="AUTO")
  23.      */
  24.     private $id;
  25.     /**
  26.      * @var string
  27.      *
  28.      * @ORM\Column(type="string", length=255)
  29.      */
  30.     private $title;
  31.     /**
  32.      * @var string
  33.      *
  34.      * @ORM\Column(type="string", length=255, nullable=true)
  35.      */
  36.     private $productVariantNoComplete;
  37.     /**
  38.      * @var int
  39.      *
  40.      * @ORM\Column(name="quantity", type="integer")
  41.      */
  42.     private $quantity;
  43.     /**
  44.      * @var float
  45.      *
  46.      * @ORM\Column(type="float", precision=18, scale=2)
  47.      */
  48.     private $priceNet;
  49.     /**
  50.      * @var float
  51.      *
  52.      * @ORM\Column(type="float", precision=18, scale=2)
  53.      */
  54.     private $priceGross;
  55.     /**
  56.      * @var float
  57.      *
  58.      * @ORM\Column(type="float", precision=18, scale=2)
  59.      */
  60.     private $priceBeforeCouponNet;
  61.     /**
  62.      * @var float
  63.      *
  64.      * @ORM\Column(type="float", precision=18, scale=2)
  65.      */
  66.     private $priceBeforeCouponGross;
  67.     /**
  68.      * @var bool
  69.      *
  70.      * @ORM\Column(type="boolean", nullable=true)
  71.      */
  72.     private $isGross;
  73.     /**
  74.      * @var bool
  75.      *
  76.      * @ORM\Column(type="boolean", nullable=true)
  77.      */
  78.     private $isFreeAccess;
  79.     /**
  80.      * @ORM\Column(type="datetime", nullable=true)
  81.      */
  82.     private $freeAccessEndAt;
  83.     /**
  84.      * @var int
  85.      *
  86.      * @ORM\Column(type="integer", options={"default" : 1})
  87.      */
  88.     private $maxUsers;
  89.     /**
  90.      * @ORM\ManyToOne(targetEntity="App\Entity\Gos\PaymentMethod", inversedBy="orderProductVariant")
  91.      * @ORM\JoinColumn()
  92.      */
  93.     private $paymentMethod;
  94.     /**
  95.      * @ORM\ManyToOne(targetEntity="App\Entity\Gos\OrderPart", inversedBy="orderProductVariant")
  96.      * @ORM\JoinColumn()
  97.      */
  98.     private $orderPart;
  99.     /**
  100.      * @ORM\OneToMany(targetEntity="App\Entity\Gos\OrderCoupon", mappedBy="orderProductVariant")
  101.      */
  102.     private $orderCoupon;
  103.     /**
  104.      * @ORM\ManyToOne(targetEntity="OrderProductVariantType", inversedBy="orderProductVariant")
  105.      * @ORM\JoinColumn()
  106.      */
  107.     private $orderProductVariantType;
  108.     /**
  109.      * @ORM\OneToMany(targetEntity="OrderProductVariantUser", mappedBy="orderProductVariant", cascade={"persist"})
  110.      */
  111.     private $orderProductVariantUser;
  112.     /**
  113.      * @ORM\OneToMany(targetEntity="App\Entity\Gos\UpdateProductVariantHistory", mappedBy="orderProductVariant")
  114.      */
  115.     private $updateProductVariantHistory;
  116.     /**
  117.      * @ORM\ManyToOne(targetEntity="App\Entity\Gos\ProductVariant", inversedBy="orderProductVariant")
  118.      * @ORM\JoinColumn()
  119.      */
  120.     private $productVariant;
  121.     /**
  122.      * @ORM\OneToMany(targetEntity="App\Entity\Gos\OrderProductVariant", mappedBy="primaryVariant")
  123.      */
  124.     private $additionalVariant;
  125.     /**
  126.      * @ORM\ManyToOne(targetEntity="App\Entity\Gos\OrderProductVariant", inversedBy="additionalVariant")
  127.      * @ORM\JoinColumn(name="primary_variant_id", referencedColumnName="id")
  128.      */
  129.     private $primaryVariant;
  130.     /**
  131.      * @ORM\ManyToOne(targetEntity="App\Entity\Gos\ProductPackItem", inversedBy="orderProductVariant")
  132.      * @ORM\JoinColumn()
  133.      */
  134.     private $productPackItem;
  135.     /**
  136.      * @ORM\OneToOne(targetEntity="Gift", mappedBy="orderProductVariant")
  137.      */
  138.     private $gift;
  139.     /**
  140.      * @ORM\Column(type="datetime")
  141.      */
  142.     private $createdAt;
  143.     /**
  144.      * @ORM\Column(type="datetime", nullable=true)
  145.      */
  146.     private $updatedAt;
  147.     /**
  148.      * @ORM\ManyToOne(targetEntity="App\Entity\Gos\Uniqskills\OrderCycle", inversedBy="orderProductVariants")
  149.      */
  150.     private $cycle;
  151.     /**
  152.      * @ORM\Column(type="boolean", nullable=true, options={"default": 0})
  153.      */
  154.     private $isReminderSend;
  155.     /**
  156.      * @ORM\Column(type="boolean", nullable=true, options={"default": 0})
  157.      */
  158.     private $isUserDone;
  159.     /**
  160.      * @ORM\Column(type="datetime", nullable=true)
  161.      */
  162.     private $showDate;
  163.     /**
  164.      * @ORM\Column(type="datetime", nullable=true)
  165.      */
  166.     private $reminderStartDate;
  167.     /**
  168.      * @ORM\Column(type="integer", nullable=true)
  169.      */
  170.     private $upsellingType;
  171.     /**
  172.      * @ORM\Column(type="boolean", nullable=true)
  173.      */
  174.     private $omittedShippingCosts;
  175.     /**
  176.      * @ORM\ManyToOne(targetEntity=Course::class)
  177.      */
  178.     private $course;
  179.     /**
  180.      * @ORM\OneToMany(targetEntity=OrderProductVariantOmittedUpsell::class, mappedBy="orderProductVariant", orphanRemoval=true)
  181.      */
  182.     private $orderProductVariantOmittedUpsells;
  183.     /**
  184.      * @ORM\OneToMany(targetEntity=EventNotificationScheduler::class, mappedBy="orderProductVariant", orphanRemoval=true, cascade={"remove"})
  185.      */
  186.     private $eventNotificationSchedulers;
  187.     /**
  188.      * @ORM\OneToMany(targetEntity=FailureEventNotifications::class, mappedBy="orderProductVariant", orphanRemoval=true, cascade={"remove"})
  189.      */
  190.     private $failureEventNotifications;
  191.     /**
  192.      * @ORM\OneToMany(targetEntity=SentEventNotifications::class, mappedBy="orderProductVariant", orphanRemoval=true, cascade={"remove"})
  193.      */
  194.     private $sentEventNotifications;
  195.     /**
  196.      * @ORM\Column(type="boolean", nullable=true)
  197.      */
  198.     private $productDuplicationMessageDisplayed;
  199.     /**
  200.      * @ORM\ManyToOne(targetEntity="App\Entity\Gos\Participants", inversedBy="orderProductVariants")
  201.      */
  202.     private $participant;
  203.     /** @ORM\PrePersist() */
  204.     public function prePersist()
  205.     {
  206.         $this->createdAt = new \DateTime();
  207.     }
  208.     /** @ORM\PreUpdate() */
  209.     public function preUpdate()
  210.     {
  211.         $this->updatedAt = new \DateTime();
  212.     }
  213.     public function __toString()
  214.     {
  215.         return (string)$this->title;
  216.     }
  217.     public function checkIfProductVariantHavePaymentMethod(string $paymentMethodSlug): bool
  218.     {
  219.         $additionalOptionsByClientType $this->getAdditionalOptionsByClientType();
  220.         if ($additionalOptionsByClientType)
  221.         {
  222.             foreach ($additionalOptionsByClientType->getPaymentMethod() as $paymentMethod)
  223.             {
  224.                 if ($paymentMethod->getSlug() === $paymentMethodSlug)
  225.                 {
  226.                     return true;
  227.                 }
  228.             }
  229.         }
  230.         return false;
  231.     }
  232.     public function checkIfProductVariantHaveToBeHiddenInSB(): bool
  233.     {
  234.         $additionalOptionsByClientType $this->getAdditionalOptionsByClientType();
  235.         if ($additionalOptionsByClientType && $additionalOptionsByClientType->getHiddenInSBTillPaid() === true)
  236.         {
  237.             return true;
  238.         }
  239.         return false;
  240.     }
  241.     public function getAdditionalOptionsByClientType(): ?AdditionalOptionsByClientType
  242.     {
  243.         return $this->getProductVariant()->getAdditionalOptionsByClientType($this->getClientTypeByOrder());
  244.     }
  245.     private function getClientTypeByOrder(): ?ClientType
  246.     {
  247.         $order $this->getOrderPart()->getOrders();
  248.         return $order->getAddress() ? $order->getAddress()->getClientType() : null;
  249.     }
  250.     /**
  251.      * Set orderPart
  252.      *
  253.      * @param OrderPart $orderPart
  254.      *
  255.      * @return OrderProductVariant
  256.      */
  257.     public function setOrderPart(OrderPart $orderPart null)
  258.     {
  259.         $this->orderPart $orderPart;
  260.         if (!empty($orderPart))
  261.         {
  262.             $orderPart->setOrderProductVariant($this);
  263.         }
  264.         return $this;
  265.     }
  266.     //------------------------------ setters & getters
  267.     /**
  268.      * Constructor
  269.      */
  270.     public function __construct()
  271.     {
  272.         $this->orderCoupon                  = new ArrayCollection();
  273.         $this->orderProductVariantUser      = new ArrayCollection();
  274.         $this->updateProductVariantHistory  = new ArrayCollection();
  275.         $this->additionalVariant            = new ArrayCollection();
  276.         $this->orderProductVariantOmittedUpsells = new ArrayCollection();
  277.     }
  278.     /**
  279.      * Get id
  280.      *
  281.      * @return integer
  282.      */
  283.     public function getId()
  284.     {
  285.         return $this->id;
  286.     }
  287.     /**
  288.      * Set title
  289.      *
  290.      * @param string $title
  291.      *
  292.      * @return OrderProductVariant
  293.      */
  294.     public function setTitle($title)
  295.     {
  296.         $this->title $title;
  297.         return $this;
  298.     }
  299.     /**
  300.      * Get title
  301.      *
  302.      * @return string
  303.      */
  304.     public function getTitle()
  305.     {
  306.         return $this->title;
  307.     }
  308.     /**
  309.      * Set productVariantNoComplete
  310.      *
  311.      * @param string $productVariantNoComplete
  312.      *
  313.      * @return OrderProductVariant
  314.      */
  315.     public function setProductVariantNoComplete($productVariantNoComplete)
  316.     {
  317.         $this->productVariantNoComplete $productVariantNoComplete;
  318.         return $this;
  319.     }
  320.     /**
  321.      * Get productVariantNoComplete
  322.      *
  323.      * @return string
  324.      */
  325.     public function getProductVariantNoComplete()
  326.     {
  327.         return $this->productVariantNoComplete;
  328.     }
  329.     /**
  330.      * Set quantity
  331.      *
  332.      * @param integer $quantity
  333.      *
  334.      * @return OrderProductVariant
  335.      */
  336.     public function setQuantity($quantity)
  337.     {
  338.         $this->quantity $quantity;
  339.         return $this;
  340.     }
  341.     /**
  342.      * Get quantity
  343.      *
  344.      * @return integer
  345.      */
  346.     public function getQuantity()
  347.     {
  348.         return $this->quantity;
  349.     }
  350.     /**
  351.      * Set priceNet
  352.      *
  353.      * @param float $priceNet
  354.      *
  355.      * @return OrderProductVariant
  356.      */
  357.     public function setPriceNet($priceNet)
  358.     {
  359.         $this->priceNet $priceNet;
  360.         return $this;
  361.     }
  362.     /**
  363.      * Get priceNet
  364.      *
  365.      * @return float
  366.      */
  367.     public function getPriceNet()
  368.     {
  369.         return $this->priceNet;
  370.     }
  371.     /**
  372.      * Set priceGross
  373.      *
  374.      * @param float $priceGross
  375.      *
  376.      * @return OrderProductVariant
  377.      */
  378.     public function setPriceGross($priceGross)
  379.     {
  380.         $this->priceGross $priceGross;
  381.         return $this;
  382.     }
  383.     /**
  384.      * Get priceGross
  385.      *
  386.      * @return float
  387.      */
  388.     public function getPriceGross()
  389.     {
  390.         return $this->priceGross;
  391.     }
  392.     /**
  393.      * Set priceBeforeCouponNet
  394.      *
  395.      * @param float $priceBeforeCouponNet
  396.      *
  397.      * @return OrderProductVariant
  398.      */
  399.     public function setPriceBeforeCouponNet($priceBeforeCouponNet)
  400.     {
  401.         $this->priceBeforeCouponNet $priceBeforeCouponNet;
  402.         return $this;
  403.     }
  404.     /**
  405.      * Get priceBeforeCouponNet
  406.      *
  407.      * @return float
  408.      */
  409.     public function getPriceBeforeCouponNet()
  410.     {
  411.         return $this->priceBeforeCouponNet;
  412.     }
  413.     /**
  414.      * Set priceBeforeCouponGross
  415.      *
  416.      * @param float $priceBeforeCouponGross
  417.      *
  418.      * @return OrderProductVariant
  419.      */
  420.     public function setPriceBeforeCouponGross($priceBeforeCouponGross)
  421.     {
  422.         $this->priceBeforeCouponGross $priceBeforeCouponGross;
  423.         return $this;
  424.     }
  425.     /**
  426.      * Get priceBeforeCouponGross
  427.      *
  428.      * @return float
  429.      */
  430.     public function getPriceBeforeCouponGross()
  431.     {
  432.         return $this->priceBeforeCouponGross;
  433.     }
  434.     /**
  435.      * Set isGross
  436.      *
  437.      * @param boolean $isGross
  438.      *
  439.      * @return OrderProductVariant
  440.      */
  441.     public function setIsGross($isGross)
  442.     {
  443.         $this->isGross $isGross;
  444.         return $this;
  445.     }
  446.     /**
  447.      * Get isGross
  448.      *
  449.      * @return boolean
  450.      */
  451.     public function getIsGross()
  452.     {
  453.         return $this->isGross;
  454.     }
  455.     /**
  456.      * Set createdAt
  457.      *
  458.      * @param \DateTime $createdAt
  459.      *
  460.      * @return OrderProductVariant
  461.      */
  462.     public function setCreatedAt($createdAt)
  463.     {
  464.         $this->createdAt $createdAt;
  465.         return $this;
  466.     }
  467.     /**
  468.      * Get createdAt
  469.      *
  470.      * @return \DateTime
  471.      */
  472.     public function getCreatedAt()
  473.     {
  474.         return $this->createdAt;
  475.     }
  476.     /**
  477.      * Set updatedAt
  478.      *
  479.      * @param \DateTime $updatedAt
  480.      *
  481.      * @return OrderProductVariant
  482.      */
  483.     public function setUpdatedAt($updatedAt)
  484.     {
  485.         $this->updatedAt $updatedAt;
  486.         return $this;
  487.     }
  488.     /**
  489.      * Get updatedAt
  490.      *
  491.      * @return \DateTime
  492.      */
  493.     public function getUpdatedAt()
  494.     {
  495.         return $this->updatedAt;
  496.     }
  497.     /**
  498.      * Set paymentMethod
  499.      *
  500.      * @param PaymentMethod $paymentMethod
  501.      *
  502.      * @return OrderProductVariant
  503.      */
  504.     public function setPaymentMethod(PaymentMethod $paymentMethod null)
  505.     {
  506.         $this->paymentMethod $paymentMethod;
  507.         return $this;
  508.     }
  509.     /**
  510.      * Get paymentMethod
  511.      *
  512.      * @return PaymentMethod
  513.      */
  514.     public function getPaymentMethod()
  515.     {
  516.         return $this->paymentMethod;
  517.     }
  518.     /**
  519.      * Get orderPart
  520.      *
  521.      * @return OrderPart
  522.      */
  523.     public function getOrderPart()
  524.     {
  525.         return $this->orderPart;
  526.     }
  527.     /**
  528.      * Add orderCoupon
  529.      *
  530.      * @param OrderCoupon $orderCoupon
  531.      *
  532.      * @return OrderProductVariant
  533.      */
  534.     public function addOrderCoupon(OrderCoupon $orderCoupon)
  535.     {
  536.         $this->orderCoupon[] = $orderCoupon;
  537.         return $this;
  538.     }
  539.     /**
  540.      * Remove orderCoupon
  541.      *
  542.      * @param OrderCoupon $orderCoupon
  543.      */
  544.     public function removeOrderCoupon(OrderCoupon $orderCoupon)
  545.     {
  546.         $this->orderCoupon->removeElement($orderCoupon);
  547.     }
  548.     /**
  549.      * Get orderCoupon
  550.      *
  551.      * @return Collection
  552.      */
  553.     public function getOrderCoupon()
  554.     {
  555.         return $this->orderCoupon;
  556.     }
  557.     /**
  558.      * Set orderProductVariantType
  559.      *
  560.      * @param OrderProductVariantType $orderProductVariantType
  561.      *
  562.      * @return OrderProductVariant
  563.      */
  564.     public function setOrderProductVariantType(
  565.         OrderProductVariantType $orderProductVariantType null
  566.     ) {
  567.         $this->orderProductVariantType $orderProductVariantType;
  568.         return $this;
  569.     }
  570.     /**
  571.      * Get orderProductVariantType
  572.      *
  573.      * @return OrderProductVariantType
  574.      */
  575.     public function getOrderProductVariantType()
  576.     {
  577.         return $this->orderProductVariantType;
  578.     }
  579.     /**
  580.      * Add orderProductVariantUser
  581.      *
  582.      * @param OrderProductVariantUser $orderProductVariantUser
  583.      *
  584.      * @return OrderProductVariant
  585.      */
  586.     public function addOrderProductVariantUser(OrderProductVariantUser $orderProductVariantUser)
  587.     {
  588.         $this->orderProductVariantUser[] = $orderProductVariantUser;
  589.         return $this;
  590.     }
  591.     /**
  592.      * Remove orderProductVariantUser
  593.      *
  594.      * @param OrderProductVariantUser $orderProductVariantUser
  595.      */
  596.     public function removeOrderProductVariantUser(
  597.         OrderProductVariantUser $orderProductVariantUser
  598.     ) {
  599.         $this->orderProductVariantUser->removeElement($orderProductVariantUser);
  600.     }
  601.     /**
  602.      * Get orderProductVariantUser
  603.      *
  604.      * @return Collection
  605.      */
  606.     public function getOrderProductVariantUser()
  607.     {
  608.         return $this->orderProductVariantUser;
  609.     }
  610.     public function isUserAdmin(User $user): bool
  611.     {
  612.         /** @var OrderProductVariantUser $opvu */
  613.         foreach ($this->orderProductVariantUser as $opvu)
  614.         {
  615.             if ($opvu->getUser() === $user)
  616.             {
  617.                 if ($opvu->getRoles() === 'ADMIN')
  618.                 {
  619.                     return true;
  620.                 }
  621.             }
  622.         }
  623.         return false;
  624.     }
  625.     /**
  626.      * Set maxUsers
  627.      *
  628.      * @param integer $maxUsers
  629.      *
  630.      * @return OrderProductVariant
  631.      */
  632.     public function setMaxUsers($maxUsers)
  633.     {
  634.         $this->maxUsers $maxUsers;
  635.         return $this;
  636.     }
  637.     /**
  638.      * Get maxUsers
  639.      *
  640.      * @return integer
  641.      */
  642.     public function getMaxUsers()
  643.     {
  644.         return $this->maxUsers;
  645.     }
  646.     /**
  647.      * Set isFreeAccess
  648.      *
  649.      * @param boolean $isFreeAccess
  650.      *
  651.      * @return OrderProductVariant
  652.      */
  653.     public function setIsFreeAccess($isFreeAccess)
  654.     {
  655.         $this->isFreeAccess $isFreeAccess;
  656.         return $this;
  657.     }
  658.     /**
  659.      * Get isFreeAccess
  660.      *
  661.      * @return boolean
  662.      */
  663.     public function getIsFreeAccess()
  664.     {
  665.         return $this->isFreeAccess;
  666.     }
  667.     /**
  668.      * Set freeAccessEndAt
  669.      *
  670.      * @param \DateTime $freeAccessEndAt
  671.      *
  672.      * @return OrderProductVariant
  673.      */
  674.     public function setFreeAccessEndAt($freeAccessEndAt)
  675.     {
  676.         $this->freeAccessEndAt $freeAccessEndAt;
  677.         return $this;
  678.     }
  679.     /**
  680.      * Get freeAccessEndAt
  681.      *
  682.      * @return \DateTime
  683.      */
  684.     public function getFreeAccessEndAt()
  685.     {
  686.         return $this->freeAccessEndAt;
  687.     }
  688.     /**
  689.      * Add updateProductVariantHistory
  690.      *
  691.      * @param UpdateProductVariantHistory $updateProductVariantHistory
  692.      *
  693.      * @return OrderProductVariant
  694.      */
  695.     public function addUpdateProductVariantHistory(
  696.         UpdateProductVariantHistory $updateProductVariantHistory
  697.     ) {
  698.         $this->updateProductVariantHistory[] = $updateProductVariantHistory;
  699.         return $this;
  700.     }
  701.     /**
  702.      * Remove updateProductVariantHistory
  703.      *
  704.      * @param UpdateProductVariantHistory $updateProductVariantHistory
  705.      */
  706.     public function removeUpdateProductVariantHistory(
  707.         UpdateProductVariantHistory $updateProductVariantHistory
  708.     ) {
  709.         $this->updateProductVariantHistory->removeElement($updateProductVariantHistory);
  710.     }
  711.     /**
  712.      * Get updateProductVariantHistory
  713.      *
  714.      * @return Collection
  715.      */
  716.     public function getUpdateProductVariantHistory()
  717.     {
  718.         return $this->updateProductVariantHistory;
  719.     }
  720.     /**
  721.      * Set productVariant
  722.      *
  723.      * @param ProductVariant $productVariant
  724.      *
  725.      * @return OrderProductVariant
  726.      */
  727.     public function setProductVariant(ProductVariant $productVariant null)
  728.     {
  729.         $this->productVariant $productVariant;
  730.         return $this;
  731.     }
  732.     /**
  733.      * Get productVariant
  734.      *
  735.      * @return ProductVariant
  736.      */
  737.     public function getProductVariant()
  738.     {
  739.         return $this->productVariant;
  740.     }
  741.     /**
  742.      * @return Collection|OrderProductVariant[]
  743.      */
  744.     public function getAdditionalVariant(): Collection
  745.     {
  746.         return $this->additionalVariant;
  747.     }
  748.     public function addAdditionalVariant(OrderProductVariant $additionalVariant): self
  749.     {
  750.         if (!$this->additionalVariant->contains($additionalVariant))
  751.         {
  752.             $this->additionalVariant[] = $additionalVariant;
  753.             $additionalVariant->setPrimaryVariant($this);
  754.         }
  755.         return $this;
  756.     }
  757.     public function removeAdditionalVariant(OrderProductVariant $additionalVariant): self
  758.     {
  759.         if ($this->additionalVariant->contains($additionalVariant))
  760.         {
  761.             $this->additionalVariant->removeElement($additionalVariant);
  762.             // set the owning side to null (unless already changed)
  763.             if ($additionalVariant->getPrimaryVariant() === $this)
  764.             {
  765.                 $additionalVariant->setPrimaryVariant(null);
  766.             }
  767.         }
  768.         return $this;
  769.     }
  770.     public function getPrimaryVariant(): ?self
  771.     {
  772.         return $this->primaryVariant;
  773.     }
  774.     public function setPrimaryVariant(?self $primaryVariant): self
  775.     {
  776.         $this->primaryVariant $primaryVariant;
  777.         return $this;
  778.     }
  779.     public function getProductPackItem(): ?ProductPackItem
  780.     {
  781.         return $this->productPackItem;
  782.     }
  783.     public function setProductPackItem(?ProductPackItem $productPackItem): self
  784.     {
  785.         $this->productPackItem $productPackItem;
  786.         return $this;
  787.     }
  788.     public function getGift(): ?Gift
  789.     {
  790.         return $this->gift;
  791.     }
  792.     public function setGift(?Gift $gift): self
  793.     {
  794.         $this->gift $gift;
  795.         // set (or unset) the owning side of the relation if necessary
  796.         $newOrderProductVariant $gift === null null $this;
  797.         if ($newOrderProductVariant !== $gift->getOrderProductVariant()) {
  798.             $gift->setOrderProductVariant($newOrderProductVariant);
  799.         }
  800.         return $this;
  801.     }
  802.     public function getCycle(): ?OrderCycle
  803.     {
  804.         return $this->cycle;
  805.     }
  806.     public function setCycle(?OrderCycle $cycle): self
  807.     {
  808.         $this->cycle $cycle;
  809.         return $this;
  810.     }
  811.     public function getIsReminderSend(): ?bool
  812.     {
  813.         return $this->isReminderSend;
  814.     }
  815.     public function setIsReminderSend(?bool $isReminderSend): self
  816.     {
  817.         $this->isReminderSend $isReminderSend;
  818.         return $this;
  819.     }
  820.     public function getIsUserDone(): ?bool
  821.     {
  822.         return $this->isUserDone;
  823.     }
  824.     public function setIsUserDone(?bool $isUserDone): self
  825.     {
  826.         $this->isUserDone $isUserDone;
  827.         return $this;
  828.     }
  829.     public function getShowDate(): ?\DateTimeInterface
  830.     {
  831.         return $this->showDate;
  832.     }
  833.     public function setShowDate(?\DateTimeInterface $showDate): self
  834.     {
  835.         $this->showDate $showDate;
  836.         return $this;
  837.     }
  838.     public function getReminderStartDate(): ?\DateTimeInterface
  839.     {
  840.         return $this->reminderStartDate;
  841.     }
  842.     public function setReminderStartDate(?\DateTimeInterface $reminderStartDate): self
  843.     {
  844.         $this->reminderStartDate $reminderStartDate;
  845.         return $this;
  846.     }
  847.     public function getUpsellingType(): ?int
  848.     {
  849.         return $this->upsellingType;
  850.     }
  851.     public function setUpsellingType(?int $upsellingType): self
  852.     {
  853.         $this->upsellingType $upsellingType;
  854.         return $this;
  855.     }
  856.     public function getOmittedShippingCosts(): ?bool
  857.     {
  858.         return $this->omittedShippingCosts;
  859.     }
  860.     public function setOmittedShippingCosts(?bool $omittedShippingCosts): self
  861.     {
  862.         $this->omittedShippingCosts $omittedShippingCosts;
  863.         return $this;
  864.     }
  865.     public function getCourse(): ?Course
  866.     {
  867.         return $this->course;
  868.     }
  869.     public function setCourse(?Course $course): self
  870.     {
  871.         $this->course $course;
  872.         return $this;
  873.     }
  874.     /**
  875.      * @return Collection|OrderProductVariantOmittedUpsell[]
  876.      */
  877.     public function getOrderProductVariantOmittedUpsells(): Collection
  878.     {
  879.         return $this->orderProductVariantOmittedUpsells;
  880.     }
  881.     public function addOrderProductVariantOmittedUpsell(OrderProductVariantOmittedUpsell $orderProductVariantOmittedUpsell): self
  882.     {
  883.         if (!$this->orderProductVariantOmittedUpsells->contains($orderProductVariantOmittedUpsell)) {
  884.             $this->orderProductVariantOmittedUpsells[] = $orderProductVariantOmittedUpsell;
  885.             $orderProductVariantOmittedUpsell->setOrderProductVariant($this);
  886.         }
  887.         return $this;
  888.     }
  889.     public function removeOrderProductVariantOmittedUpsell(OrderProductVariantOmittedUpsell $orderProductVariantOmittedUpsell): self
  890.     {
  891.         if ($this->orderProductVariantOmittedUpsells->contains($orderProductVariantOmittedUpsell)) {
  892.             $this->orderProductVariantOmittedUpsells->removeElement($orderProductVariantOmittedUpsell);
  893.             // set the owning side to null (unless already changed)
  894.             if ($orderProductVariantOmittedUpsell->getOrderProductVariant() === $this) {
  895.                 $orderProductVariantOmittedUpsell->setOrderProductVariant(null);
  896.             }
  897.         }
  898.         return $this;
  899.     }
  900.     public function getProductDuplicationMessageDisplayed(): ?bool
  901.     {
  902.         return $this->productDuplicationMessageDisplayed;
  903.     }
  904.     public function setProductDuplicationMessageDisplayed(?bool $productDuplicationMessageDisplayed): self
  905.     {
  906.         $this->productDuplicationMessageDisplayed $productDuplicationMessageDisplayed;
  907.         return $this;
  908.     }
  909.     public function getCalculatedDiscountPercentage(): float
  910.     {
  911.         $discount 0.0;
  912.         $priceBeforeCouponGross $this->getPriceBeforeCouponGross();
  913.         $priceGross $this->getPriceGross();
  914.         if ($priceBeforeCouponGross !== $priceGross) {
  915.             $discount = (($priceBeforeCouponGross $priceGross) / $priceBeforeCouponGross) * 100;
  916.             $discount round($discount2);
  917.         }
  918.         return $discount;
  919.     }
  920.     public function isFromCompositeProduct(): bool
  921.     {
  922.         $productVariant $this->getProductVariant();
  923.         return $productVariant && $productVariant->getMasterProduct() !== $productVariant->getTradeProduct();
  924.     }
  925.     public function isEvent(): bool
  926.     {
  927.         return $this->getProductVariant() && $this->getProductVariant()->isEvent();
  928.     }
  929.     public function getParticipant(): ?Participants
  930.     {
  931.         return $this->participant;
  932.     }
  933.     public function setParticipant(?Participants $participant): self
  934.     {
  935.         $this->participant $participant;
  936.         return $this;
  937.     }
  938.     public function hasEventInAWeek(): bool
  939.     {
  940.         $now = new \DateTime();
  941.         $weekFromNow = (new \DateTime())->modify('+7 day');
  942.         $event $this->getEvent();
  943.         return $event && $event->getStartAt() >= $now && $event->getStartAt() <= $weekFromNow;
  944.     }
  945.     public function getEvent(): ?Events
  946.     {
  947.         return $this->getProductPackItem()
  948.             ? $this->getProductPackItem()->getProductPack()?->getEvent()
  949.             : $this->getProductVariant()->getEvent();
  950.     }
  951. }