<?php
namespace App\Entity\Gos;
use App\Entity\Gos\Uniqskills\Course;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* Cart
*
* @ORM\Table(name="cart")
* @ORM\Entity(repositoryClass="App\Repository\CartRepository")
* @ORM\HasLifecycleCallbacks
*/
class Cart
{
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="hash", type="string", length=255, unique=true)
*/
private $hash;
/**
* @var bool
*
* @ORM\Column(type="boolean", nullable=true)
*/
private $model;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Gos\CouponPending", mappedBy="cart", cascade={"persist"})
*/
private $couponPending;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Gos\Coupon", inversedBy="cart", cascade={"persist"})
* @ORM\JoinColumn()
*
* TODO: DEV-171 Zostawilem to pole dla pewnosci zeby nic sie nie wysypalo
* Jesli wszystko zacznie uzywac multi kuponow bedzie mozna usunac to pole
*/
private $coupon;
/**
* @ORM\ManyToMany(targetEntity="App\Entity\Gos\Coupon", inversedBy="carts", cascade={"persist"})
* @ORM\JoinTable(name="carts_coupons")
*/
private $coupons;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Gos\ProductCart", mappedBy="cart", cascade={"persist"})
*/
private $productCart;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Gos\Address", inversedBy="cart", cascade={"persist"})
* @ORM\JoinColumn()
*/
private $address;
/**
* @ORM\OneToOne(targetEntity="App\Entity\Gos\User", inversedBy="cart")
* @ORM\JoinColumn(onDelete="SET NULL")
*/
private $user;
/**
* @ORM\OneToOne(targetEntity="App\Entity\Gos\UserTemporary", inversedBy="cart", cascade={"persist"})
* @ORM\JoinColumn(onDelete="SET NULL")
*/
private $userTemporary;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $hasMultiDiscount;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $selectedDiscount;
/**
* @ORM\ManyToOne(targetEntity="Country", inversedBy="carts")
* @ORM\JoinColumn()
*/
private $country;
/**
* @ORM\Column(type="integer", options={"default": 0})
*/
private $extendedPaymentTime = 0;
/**
* @ORM\ManyToOne(targetEntity="PaymentMethod", inversedBy="cart")
* @ORM\JoinColumn()
*/
private $paymentMethod;
/**
* @ORM\ManyToOne(targetEntity="PaymentSystem", inversedBy="cart")
* @ORM\JoinColumn()
*/
private $paymentSystem;
/**
* @ORM\Column(type="datetime")
*/
private $createdAt;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $updatedAt;
/**
* @ORM\ManyToOne(targetEntity=PortalSettings::class, inversedBy="carts")
*/
private $portalSettings;
/**
* @ORM\ManyToOne(targetEntity=ShippingType::class)
*/
private $shippingType;
/**
* @ORM\Column(type="boolean", options={"default": false})
*/
private $sentToSm = false;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $burAssignedSupportId;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $salesManago2EventId;
public function isActive()
{
foreach ($this->getProductCart() as $productCart)
{
/** @var ProductCart $productCart */
if (!$productCart->isActive())
{
return false;
}
}
return true;
}
public function __clone()
{
if ($this->id)
{
$this->setId(null);
}
}
/** @ORM\PrePersist() */
public function prePersist()
{
$this->createdAt = new \DateTime();
}
/** @ORM\PreUpdate() */
public function preUpdate()
{
$this->updatedAt = new \DateTime();
}
public function __toString()
{
return (string)$this->hash;
}
public function getCourse(): ?Course
{
/** @var ProductCart $productCart */
foreach ($this->getProductCart() as $productCart)
{
if ($productCart->getCourse())
{
return $productCart->getCourse();
}
}
return null;
}
public function showButtonAdditionalAddress(): bool
{
if (!$this->getProductCart()->isEmpty())
{
/** @var ProductCart $productCart */
foreach ($this->getProductCart() as $productCart)
{
if ($productCart->getProductPack())
{
foreach ($productCart->getProductPack()->getProductPackItem() as $item)
{
if ($item->getProductVariant()->getShowButtonAdditionalAddress() === true) return true;
}
}
else if ($productCart->getProductVariant() && $productCart->getProductVariant()->getShowButtonAdditionalAddress() === true)
{
return true;
}
}
}
return false;
}
public function hasProductVariant(ProductVariant $productVariant): bool
{
/** @var ProductCart $productCart */
foreach ($this->productCart as $productCart)
{
if ($productCart->getProductVariant() === $productVariant)
{
return true;
}
}
return false;
}
public function hasOnlyDigitalProducts(): bool
{
if (!$this->getProductCart()->isEmpty())
{
/** @var ProductCart $productCart */
foreach ($this->getProductCart() as $productCart)
{
if ($productCart->getProductPack())
{
foreach ($productCart->getProductPack()->getProductPackItem() as $item)
{
if (!$item->getProductVariant()->getIsDigital())
{
return false;
}
}
}
else if ($productCart->getProductVariant() && !$productCart->getProductVariant()->getIsDigital())
{
return false;
}
}
}
return true;
}
public function hasEventProduct(): bool
{
if (!$this->getProductCart()->isEmpty())
{
foreach ($this->getProductCart() as $productCart)
{
/** @var ProductCart $productCart */
if ($productCart->hasEventProduct())
{
return true;
}
}
}
return false;
}
public function hasEventProductTaxFree(): bool
{
if (!$this->getProductCart()->isEmpty())
{
foreach ($this->getProductCart() as $productCart)
{
/** @var ProductCart $productCart */
if ($productCart->hasEventProductTaxFree())
{
return true;
}
}
}
return false;
}
public function hasOnlyEventProduct(): bool
{
if (!$this->getProductCart()->isEmpty())
{
foreach ($this->getProductCart() as $productCart)
{
/** @var ProductCart $productCart */
if (!$productCart->hasOnlyEventProduct())
{
return false;
}
}
}
return true;
}
/**
* Return prodcutCart when has event product
* @return array
*/
public function getEventProductCart(): array
{
$productsCart = array();
if (!$this->getProductCart()->isEmpty())
{
foreach ($this->getProductCart() as $productCart)
{
/** @var ProductCart $productCart */
if ($productCart->hasEventProduct())
{
$productsCart[] = $productCart;
}
}
}
return $productsCart;
}
public function hasUniqskillsMultiUserCourse()
{
return !empty(array_filter($this->getProductCart()->toArray(), function($productCart)
{
return $productCart->getProductVariant() !== null
&& $productCart->getProductVariant()->getIsUniqskillsProduct()
&& $productCart->getProductVariant()->getMaxUsers() > 1
&& $productCart->getProductVariant()->getBuyMaxOne() === false
&& $productCart->getQuantity() > 1;
}));
}
public function getUniqskillsMultiUserCourse()
{
return array_filter($this->getProductCart()->toArray(), function($productCart)
{
return $productCart->getProductVariant() !== null
&& $productCart->getProductVariant()->getIsUniqskillsProduct()
&& $productCart->getProductVariant()->getMaxUsers() > 1
&& $productCart->getProductVariant()->getBuyMaxOne() === false;
});
}
//------------------------------ setters & getters
/**
* Set id
*
* @return Cart
*/
public function setId($id)
{
$this->id = $id;
return $this;
}
/**
* Constructor
*/
public function __construct()
{
$this->productCart = new ArrayCollection();
$this->couponPending = new ArrayCollection();
$this->coupons = new ArrayCollection();
}
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set hash
*
* @param string $hash
*
* @return Cart
*/
public function setHash($hash)
{
$this->hash = $hash;
return $this;
}
/**
* Get hash
*
* @return string
*/
public function getHash()
{
return $this->hash;
}
/**
* Set model
*
* @param boolean $model
*
* @return Cart
*/
public function setModel($model)
{
$this->model = $model;
return $this;
}
/**
* Get model
*
* @return boolean
*/
public function getModel()
{
return $this->model;
}
/**
* Set createdAt
*
* @param \DateTime $createdAt
*
* @return Cart
*/
public function setCreatedAt($createdAt)
{
$this->createdAt = $createdAt;
return $this;
}
/**
* Get createdAt
*
* @return \DateTime
*/
public function getCreatedAt()
{
return $this->createdAt;
}
/**
* Set updatedAt
*
* @param \DateTime $updatedAt
*
* @return Cart
*/
public function setUpdatedAt($updatedAt)
{
$this->updatedAt = $updatedAt;
return $this;
}
/**
* Get updatedAt
*
* @return \DateTime
*/
public function getUpdatedAt()
{
return $this->updatedAt;
}
/**
* Set couponPending
* @deprecated Please use addCouponPending
*
* @param CouponPending $couponPending
*
* @return Cart
*/
public function setCouponPending(CouponPending $couponPending = null): Cart
{
if ($couponPending) {
return $this->addCouponPending($couponPending);
}
return $this;
}
/**
* Add couponPending
*
* @param CouponPending $couponPending
*
* @return $this
*/
public function addCouponPending(CouponPending $couponPending): Cart
{
if (!$this->couponPending->contains($couponPending))
{
$this->couponPending->add($couponPending);
$couponPending->setCart($this);
}
return $this;
}
/**
* Remove couponPending
*
* @param CouponPending $couponPending
*
* @return $this
*/
public function removeCouponPending(CouponPending $couponPending): Cart
{
if ($this->couponPending->contains($couponPending))
{
$this->couponPending->removeElement($couponPending);
$couponPending->setCart(null);
}
return $this;
}
/**
* Get couponPending
*
* @return Collection
*/
public function getCouponPending()
{
return $this->couponPending;
}
/**
* Set coupon
*
* @param Coupon|null $coupon
* @deprecated Please use addCupon instead
*
* TODO: DEV-171 Zostawielem ta funkcje dla pewnosci zeby nic sie nie wysypalo
* Jesli wszystko zacznie uzywac multi kuponow bedzie mozna ja usunac
*
* @return Cart
*/
public function setCoupon(Coupon $coupon = null)
{
if ($this->coupon !== null && $this->coupons->contains($this->coupon))
{
$this->coupons->removeElement($this->coupon);
}
if ($coupon !== null && !$this->coupons->contains($coupon))
{
$this->coupons->add($coupon);
}
$this->coupon = $coupon;
return $this;
}
/**
* Set coupons
*
* @param Collection $coupons
*
* @return Cart
*/
public function setCoupons(Collection $coupons)
{
if ($coupons->isEmpty())
{
$this->coupon = null;
}
$this->coupons = $coupons;
/** @var Coupon $coupon */
foreach ($coupons as $coupon) {
$coupon->addCarts($this);
}
return $this;
}
/**
* Add coupon
*
* @param Coupon $coupon
*
* @return Cart
*/
public function addCoupon(Coupon $coupon)
{
if(!$this->coupons->contains($coupon))
{
$this->coupons->add($coupon);
$coupon->addCarts($this);
}
return $this;
}
/**
* Remove coupon
*
* @param Coupon $coupon
*
* @return Cart
*/
public function removeCoupon(Coupon $coupon)
{
if($this->coupons->contains($coupon))
{
$this->coupons->removeElement($coupon);
$coupon->removeCarts($this);
}
if ($this->coupon === $coupon)
{
$this->coupon = null;
}
return $this;
}
/**
* Get coupon
* @deprecated Please use getCoupons instead
*
* TODO: DEV-171 Zostawielem ta funkcje dla pewnosci zeby nic sie nie wysypalo
* Jesli wszystko zacznie uzywac multi kuponow bedzie mozna usunac ta funkcje
*
* @return Coupon
*/
public function getCoupon()
{
if ($this->coupons->isEmpty())
{
return $this->coupon;
}
return $this->coupons->first();
}
/**
* Get coupons
*
* @return Collection
*/
public function getCoupons()
{
return $this->coupons;
}
/**
* Add productCart
*
* @param \App\Entity\Gos\ProductCart $productCart
*
* @return Cart
*/
public function addProductCart(\App\Entity\Gos\ProductCart $productCart)
{
$this->productCart[] = $productCart;
$this->getPaymentSystems();
return $this;
}
/**
* Remove productCart
*
* @param \App\Entity\Gos\ProductCart $productCart
*/
public function removeProductCart(\App\Entity\Gos\ProductCart $productCart)
{
$this->productCart->removeElement($productCart);
}
/**
* Get productCart
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getProductCart()
{
return $this->productCart;
}
public function hasProducts()
{
return $this->productCart->first();
}
/**
* @return Collection|ProductVariant[]
*/
public function getAllProductVariants(): Collection
{
$productVariants = new ArrayCollection();
foreach ($this->productCart as $productCart)
{
/** @var ProductCart $productCart */
if ($productCart->getProductVariant())
{
$productVariants->add($productCart->getProductVariant());
}
elseif ($productCart->getProductPack())
{
foreach ($productCart->getProductPack()->getProductPackItem() as $productPackItem)
{
if ($productPackItem->getProductVariant())
{
$productVariants->add($productPackItem->getProductVariant());
}
}
}
}
return $productVariants;
}
public function checkCartHasOnlyProductPact(): bool
{
if ($this->getProductCart()->isEmpty())
{
return false;
}
/** @var ProductCart $productCart */
foreach ($this->getProductCart() as $productCart)
{
if (is_null($productCart->getProductPack()))
{
return false;
}
}
return true;
}
public function omittedShippingCostsInAllProducts(): bool
{
foreach ($this->productCart as $productCart)
{
/** @var ProductCart $productCart */
if (!$productCart->getOmitShippingCosts())
{
return false;
}
}
return true;
}
public function checkProlongationVariantInCart()
{
foreach ($this->productCart as $productCart)
{
/** @var ProductCart $productCart */
if ($productVariant = $productCart->getProductVariant())
{
if (substr($productVariant->getProductVariantNoComplete(), 0, 1) == '2')
{
return true;
}
}
}
return false;
}
/**
* Set address
*
* @param \App\Entity\Gos\Address $address
*
* @return Cart
*/
public function setAddress(\App\Entity\Gos\Address $address = null)
{
$this->address = $address;
return $this;
}
/**
* Get address
*
* @return \App\Entity\Gos\Address
*/
public function getAddress()
{
return $this->address;
}
/**
* Set user
*
* @param \App\Entity\Gos\User $user
*
* @return Cart
*/
public function setUser(\App\Entity\Gos\User $user = null)
{
$this->user = $user;
return $this;
}
/**
* Get user
*
* @return \App\Entity\Gos\User
*/
public function getUser()
{
return $this->user;
}
public function getUserTemporary(): ?UserTemporary
{
return $this->userTemporary;
}
public function setUserTemporary(?UserTemporary $userTemporary): self
{
$this->userTemporary = $userTemporary;
return $this;
}
public function getExtendedPaymentTime(): ?int
{
return $this->extendedPaymentTime;
}
public function setExtendedPaymentTime(int $extendedPaymentTime): self
{
$this->extendedPaymentTime = $extendedPaymentTime;
return $this;
}
public function getHasMultiDiscount(): ?bool
{
return $this->hasMultiDiscount;
}
public function setHasMultiDiscount(?bool $hasMultiDiscount): self
{
$this->hasMultiDiscount = $hasMultiDiscount;
return $this;
}
public function getSelectedDiscount(): ?int
{
return $this->selectedDiscount;
}
public function setSelectedDiscount(?int $selectedDiscount): self
{
$this->selectedDiscount = $selectedDiscount;
return $this;
}
public function getClientType(): ?ClientType
{
if (empty($this->address) || empty($this->getAddress()->getClientType()))
{
return null;
}
return $this->getAddress()->getClientType();
}
public function getClientTypeName(): ?string
{
return $this->getClientType() ? $this->getClientType()->getName() : null;
}
public function hasProductCartToGift(): bool
{
if (!empty($this->productCart))
{
foreach ($this->productCart as $productCart)
{
/** @var ProductCart $productCart */
if (!empty($productCart->getGift()) || $productCart->getIsGift())
{
return true;
}
}
}
return false;
}
public function getProductsCartToGift()
{
if (!empty($this->productCart))
{
return $this->getProductCart()->filter(
function ($productCart) {
return $productCart->getGift();
}
);
}
return [];
}
public function getCountry(): ?Country
{
return $this->country;
}
public function setCountry(?Country $country): self
{
$this->country = $country;
return $this;
}
public function shouldShowGrossPrice(): bool
{
return $this->getPortalSettings() ? $this->getPortalSettings()->getShowGrossPrice() : false;
}
public function hasOnlyUniqskillsProducts(): bool
{
foreach ($this->getAllProductVariants() as $productVariant)
{
if ($productVariant->getCourses()->isEmpty())
{
return false;
}
}
return true;
}
public function getPaymentSystems(): array
{
$paymentSystems = [];
// if ($this->hasOnlyUniqskillsProducts())
// {
if (empty($this->getAllProductVariants()))
{
$this->setPaymentSystem(null);
return $paymentSystems;
}
foreach ($this->getAllProductVariants() as $index => $productVariant)
{
if ($index === 0)
{
foreach ($productVariant->getPaymentSystem() as $paymentSystem)
{
if ($paymentSystem->getIsActive() === false)
{
continue;
}
if ($this->hasProductCartToGift() && $paymentSystem->getSlug() === 'proforma-invoice')
{
continue;
}
$paymentSystems[$paymentSystem->getSlug()] = $paymentSystem;
}
}
else
{
foreach ($paymentSystems as $key => $paymentSystem)
{
if (!in_array($paymentSystem, $productVariant->getPaymentSystem()->toArray()))
{
unset($paymentSystems[$key]);
}
}
}
}
uasort($paymentSystems, function (PaymentSystem $paymentSystemA, PaymentSystem $paymentSystemB) {
return $paymentSystemA->getPosition($this->getCountry(), $this->portalSettings) <=> $paymentSystemB->getPosition($this->getCountry(), $this->portalSettings);
});
if (!empty($paymentSystems) && empty($this->getPaymentSystem()))
{
$this->setPaymentSystem(reset($paymentSystems));
}
// }
// elseif (empty($this->getCountry()) || $this->getCountry()->getSlug() == 'poland')
// {
// $paymentSystems[] = (new PaymentSystem())
// ->setName($this->getInvoicePaymentTitle())
// ->setSlug('invoice')
// ->setIsActive(true);
//
// $this->setPaymentSystem(null);
// }
return $paymentSystems;
}
public function getPaymentMethod(): ?PaymentMethod
{
return $this->paymentMethod;
}
public function setPaymentMethod(?PaymentMethod $paymentMethod): self
{
$this->paymentMethod = $paymentMethod;
return $this;
}
public function getPaymentSystem(): ?PaymentSystem
{
return $this->paymentSystem;
}
public function setPaymentSystem(?PaymentSystem $paymentSystem): self
{
$this->paymentSystem = $paymentSystem;
return $this;
}
public function canBePaidForWithOnline()
{
/** @var ProductCart $productCart */
foreach ($this->productCart as $productCart)
{
$hasOnline = array_filter($productCart->getAvailablePaymentMethods(),
function($val) {return $val->getSlug() == 'online';});
if (empty($hasOnline))
{
return false;
}
}
return true;
}
public function mustBeHiddenInSB()
{
$clientType = $this->getAddress() ? $this->getAddress()->getClientType() : null;
/** @var ProductCart $productCart */
foreach ($this->productCart as $productCart)
{
if ($productCart->getProductVariant() !== null) {
$additionalOptionsByClientType = $productCart->getProductVariant()->getAdditionalOptionsByClientType($clientType);
if ($additionalOptionsByClientType && $additionalOptionsByClientType->getHiddenInSBTillPaid() === true) {
return true;
}
}
if ($productCart->getProductPack() !== null) {
foreach ($productCart->getProductPack()->getProductPackItem() as $productPackItem) {
$additionalOptionsByClientType = $productPackItem->getProductVariant()->getAdditionalOptionsByClientType($clientType);
if ($additionalOptionsByClientType && $additionalOptionsByClientType->getHiddenInSBTillPaid() === true) {
return true;
}
}
}
}
return false;
}
public function getProductsWithDelayedProformaPayment()
{
$products = array();
/** @var ProductCart $productCart */
foreach ($this->productCart as $productCart)
{
if ($productCart->getProductPack())
{
if (count($productCart->getProductPack()->getProductPackItem()))
{
foreach ($productCart->getProductPack()->getProductPackItem() as $productPackItem)
{
if ($productPackItem->getProductVariant()
->checkIfProductVariantHavePaymentMethod($this->getClientType(), 'delayed-proforma'))
{
$products[] = $productPackItem->getProductVariant();
}
}
}
}
else
{
if ($productCart->getProductVariant())
{
if ($productCart->getProductVariant()
->checkIfProductVariantHavePaymentMethod($this->getClientType(), 'delayed-proforma'))
{
$products[] = $productCart->getProductVariant();
}
}
}
}
return $products;
}
public function getProductsWithInvoicePayment()
{
$products = array();
/** @var ProductCart $productCart */
foreach ($this->productCart as $productCart)
{
foreach ($productCart->getAvailablePaymentMethods() as $paymentMethod)
{
if ($paymentMethod->getSlug() == 'invoice')
{
$products[] = $productCart;
}
}
}
return $products;
}
public function getProductsWithProformaPayment()
{
$products = array();
/** @var ProductCart $productCart */
foreach ($this->productCart as $productCart)
{
foreach ($productCart->getAvailablePaymentMethods() as $paymentMethod)
{
if ($paymentMethod->getSlug() == 'proforma-invoice')
{
$products[] = $productCart;
}
}
}
return $products;
}
public function hasProductsWithRecurringPayment(): bool
{
/** @var ProductCart $productCart */
foreach ($this->productCart as $productCart)
{
if ($productCart->getProductVariant())
{
if ($productCart->getProductVariant()->getIsRecurringSubscription() === true)
{
return true;
}
}
}
return false;
}
public function getInvoicePaymentTitle()
{
if (!empty($this->getProductsWithDelayedProformaPayment()))
{
return 'Faktura pro forma';
}
if (!empty($this->getProductsWithInvoicePayment()) && !empty($this->getProductsWithProformaPayment()))
{
$title = 'Faktury: VAT oraz pro-forma';
}
elseif (!empty($this->getProductsWithProformaPayment()))
{
$title = 'Faktura pro-forma';
}
else
{
$title = 'Faktura VAT';
}
if ($this->canBePaidForWithOnline())
{
if ($this->mustBeHiddenInSB())
$title = 'Płatność online';
else
$title .= ' z możliwością opłacenia online';
}
return $title;
}
public function hasCycleProducts(): bool
{
/** @var ProductCart $productCart */
foreach ($this->getProductCart() as $productCart)
{
if ($productCart->getCycleProductPack())
{
return true;
}
}
return false;
}
public function getCycleProducts(): array
{
$cycleProducts = array();
/** @var ProductCart $productCart */
foreach ($this->getProductCart() as $productCart)
{
if ($productCart->getCycleProductPack())
{
$cycleProducts[] = $productCart->getProductVariant();
}
}
return $cycleProducts;
}
public function getAvailableClientTypes()
{
$clientTypes = [];
$quantity = 0;
/** @var ProductCart $productCart */
foreach ($this->productCart as $productCart)
{
$clientTypes = array_merge($clientTypes, $productCart->getAvailableClientTypes()['types']);
$quantity += $productCart->getAvailableClientTypes()['quantity'];
}
$count = array_count_values(array_map(function ($clientType) {
return $clientType->getId();
}, $clientTypes));
$arr = [];
foreach ($count as $key => $item)
{
// if all product variants have the same clientType
if($quantity == $item) $arr[] = $this->findClientTypeById($key, $clientTypes);
}
return $arr;
}
private function findClientTypeById($id, $clientTypes)
{
foreach ($clientTypes as $clientType)
{
if($clientType->getId() == $id)
{
return $clientType;
}
}
return false;
}
public function getPortalSettings(): ?PortalSettings
{
return $this->portalSettings;
}
public function setPortalSettings(?PortalSettings $portalSettings): self
{
$this->portalSettings = $portalSettings;
return $this;
}
public function isEmailInvoiceEnabled(): bool
{
$emailInvoiceEnabled = true;
/** @var ProductCart $cartProduct */
foreach ($this->getProductCart() as $cartProduct)
{
if (!$cartProduct->getEmailInvoiceEnabled())
{
$emailInvoiceEnabled = false;
break;
}
}
return $emailInvoiceEnabled;
}
public function askForPWZ(): bool
{
/** @var ProductCart $productCart */
foreach ($this->getProductCart() as $productCart)
{
if ($productCart->askForPWZ())
{
return true;
}
}
return false;
}
public function isNPWZRequired(): bool
{
/** @var ProductCart $productCart */
foreach ($this->getProductCart() as $productCart)
{
if ($productCart->isNPWZRequired())
{
return true;
}
}
return false;
}
public function getShippingType(): ?ShippingType
{
return $this->shippingType;
}
public function setShippingType(?ShippingType $shippingType): self
{
$this->shippingType = $shippingType;
return $this;
}
public function isSentToSm(): ?bool
{
return $this->sentToSm;
}
public function setSentToSm(bool $sentToSm): self
{
$this->sentToSm = $sentToSm;
return $this;
}
public function validateCoupons(): void
{
/** @var Coupon $coupon */
foreach ($this->getCoupons() as $coupon) {
if ($coupon->isValid() === false) {
$this->removeCoupon($coupon);
}
}
/** @var ProductCart $productCart */
foreach ($this->getProductCart() as $productCart) {
foreach ($productCart->getCoupons() as $coupon) {
if ($coupon->isValid() === false) {
$productCart->removeCoupon($coupon);
}
}
}
}
public function getBurAssignedSupportId(): ?string
{
return $this->burAssignedSupportId;
}
public function setBurAssignedSupportId(?string $burAssignedSupportId): self
{
$this->burAssignedSupportId = $burAssignedSupportId;
return $this;
}
public function getSalesManago2EventId(): ?string
{
return $this->salesManago2EventId;
}
public function setSalesManago2EventId(string $salesManago2EventId): self
{
$this->salesManago2EventId = $salesManago2EventId;
return $this;
}
}