<?php
namespace App\Entity\System;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\ORM\Mapping\JoinColumn;
use Doctrine\ORM\Mapping\OneToOne;
/**
* Cart
*
* @ORM\Table(name="ps_cart")
*
* @ORM\Entity(repositoryClass="App\Repository\System\CartRepository")
*/
class Cart
{
public const DEFAULT_CURRENCY_EUR = 1;
/**
* @var int
*
* @ORM\Id
*
* @ORM\GeneratedValue(strategy="AUTO")
*
* @ORM\Column(type="integer", name="id_cart")
*/
private $id;
/**
* One Cart has One Order.
*
* @var Order|null
*
* @OneToOne(targetEntity="App\Entity\System\Order", inversedBy="cart")
*
* @JoinColumn(name="id_order", referencedColumnName="id_order", nullable=true)
*/
private $order;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\System\Carrier")
*
* @ORM\JoinColumn(name="id_carrier", referencedColumnName="id_carrier", nullable=true)
*/
private ?Carrier $carrier;
/**
* @var string
*
* @ORM\Column(type="string", length=1000)
*/
private $deliveryOption;
/**
* @var int
*
* @ORM\Column(type="integer", length=10, name="id_lang")
*/
private $LanguageId;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\System\Address")
*
* @ORM\JoinColumn(referencedColumnName="id_address", name="id_address_delivery", nullable=true)
*/
private ?Address $addressDelivery;
/**
* @deprecated la dirección de facturación es la del cliente del carrito
*
* @ORM\ManyToOne(targetEntity="App\Entity\System\Address")
*
* @ORM\JoinColumn(referencedColumnName="id_address", name="id_address_invoice", nullable=true)
*/
private ?Address $addressInvoice;
/**
* @var int
*
* @ORM\Column(type="integer", length=10, name="id_currency")
*/
private $currencyId;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\System\Customer")
*
* @ORM\JoinColumn(name="id_customer", referencedColumnName="id_customer", nullable=true)
*/
private ?Customer $customer;
/**
* @var int
*
* @ORM\Column(type="integer", length=10, name="id_guest")
*/
private $guestId;
/**
* @var string|null
*
* @ORM\Column(type="string", length=32, nullable=true, options={"default" : "-1"})
*/
private $secureKey;
/**
* @var int
*
* @ORM\Column(type="boolean", columnDefinition="tinyint(1)", options={"default" : 1})
*/
private $recyclable;
/**
* @var \DateTime
*
* @ORM\Column(type="datetime")
*/
private $dateUpd;
/**
* @var \DateTime
*
* @ORM\Column(type="datetime")
*/
private $dateAdd;
/**
* @var int
*
* @ORM\Column(type="boolean", columnDefinition="tinyint(1)", options={"default" : 0}, name="is_virtual")
*/
private $virtual;
/**
* @var bool
*
* @ORM\Column(type="boolean", columnDefinition="tinyint(4)", options={"default" : 0}, name="is_sync")
*/
private bool $sync;
/**
* @var int
*
* @ORM\Column(type="integer", length=11, options={"default" : 0}, name="id_sincronate_shop_configuration")
*/
private $sincronateShopConfigurationId;
/**
* @var int|null
*
* @ORM\Column(type="boolean", columnDefinition="tinyint(1)", options={"default" : 0}, name="is_mobile", nullable=true)
*/
private $mobile;
/**
* @var int|null
*
* @ORM\Column(type="boolean", columnDefinition="tinyint(1)", options={"default" : 0}, nullable=true)
*/
private $dropshipping;
/**
* @var string|null
*
* @ORM\Column(type="string", nullable=true)
*/
private $payment;
/**
* @var string|null
*
* @ORM\Column(type="string", length=64, nullable=true)
*/
private ?string $paymentMethodType = null;
/**
* @var string|null
*
* @ORM\Column(type="string", length=64, nullable=true)
*/
private ?string $paymentMethodId = null;
/**
* One Cart has One PackPaymentMethod.
*
* @var PaymentMethod|null
*
* @ORM\ManyToOne(targetEntity="App\Entity\System\PaymentMethod", inversedBy="packCarts")
*
* @JoinColumn(name="pack_payment_method_id", referencedColumnName="id_payment_method", nullable=true)
*/
private $packPaymentMethod;
/**
* @var string|null
*
* @ORM\Column(type="string", nullable=true)
*/
private $packStoredPaymentMethodId;
/**
* One Cart has One ServicesPaymentMethod.
*
* @var PaymentMethod|null
*
* @ORM\ManyToOne(targetEntity="App\Entity\System\PaymentMethod", inversedBy="servicesCarts")
*
* @JoinColumn(name="services_payment_method_id", referencedColumnName="id_payment_method", nullable=true)
*/
private $servicesPaymentMethod;
/**
* @var string|null
*
* @ORM\Column(type="string", nullable=true)
*/
private $servicesStoredPaymentMethodId;
/**
* @var float|null
*
* @ORM\Column(type="float", columnDefinition="decimal(17,2)", options={"default" : 0.00}, nullable=true)
*/
private $totalProducts;
/**
* @var float|null
*
* @ORM\Column(type="float", columnDefinition="decimal(17,2)", options={"default" : 0.00}, nullable=true, name="total_envio")
*/
private $totalShipping;
/**
* @ORM\Column(type="float", nullable=true, name="logistic_weight")
*/
private ?float $logisticWeight;
/**
* @var CartProduct[]|ArrayCollection
*
* @ORM\OneToMany(targetEntity="CartProduct", mappedBy="cart", cascade={"persist"})
*/
private $cartProducts;
/**
* @ORM\Column(type="string", length=40, nullable=true)
*/
private ?string $carrierComment = null;
/**
* @ORM\Column(type="string", length=50, nullable=true)
*/
private ?string $refOrderSupplier = null;
/**
* @ORM\Column(type="boolean", columnDefinition="tinyint(1)", options={"default" : 0}, name="is_system")
*/
private bool $system = false;
/**
* @ORM\Column(type="string", length=64, nullable=true)
*/
private ?string $sellingChannel = null;
/**
* @ORM\Column(type="string", length=256, nullable=true)
*/
private ?string $additionalParameters = null;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private ?\DateTime $dateAmazon = null;
/**
* @ORM\Column(type="boolean", columnDefinition="tinyint(1)", options={"default" : 0})
*/
private bool $fba = false;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private ?\DateTime $maxDeliveryDatetime = null;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private ?\DateTime $maxExpeditionDatetime = null;
/**
* @ORM\Column(type="text", nullable=true)
*/
private ?string $shipmentChoices = null;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\System\CodeDiscount")
*
* @ORM\JoinColumn(name="code_discount_id", referencedColumnName="id", nullable=true, onDelete="SET NULL")
*/
private ?CodeDiscount $codeDiscount = null;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\System\Cart", inversedBy="cartChildren")
*
* @ORM\JoinColumn(name="cart_parent_id", referencedColumnName="id_cart", nullable=true)
*/
private ?Cart $cartParent = null;
/**
* @var ArrayCollection<int, Cart>|Cart[]
*
* @ORM\OneToMany(targetEntity="App\Entity\System\Cart", mappedBy="cartParent")
*/
private $cartChildren;
public function __construct()
{
$this->currencyId = 0;
$this->guestId = 0;
$this->recyclable = false;
$this->sync = false;
$this->sincronateShopConfigurationId = 0;
$this->logisticWeight = 0;
$this->cartProducts = new ArrayCollection();
$this->cartChildren = new ArrayCollection();
}
/**
* @return int
*/
public function getId(): int
{
return $this->id;
}
/**
* @param int|null $id
*
* @return Cart
*/
public function setIdCart(?int $id): Cart
{
$this->id = $id;
return $this;
}
/**
* @return Order|null
*/
public function getOrder(): ?Order
{
return $this->order;
}
/**
* @param Order|null $order
*
* @return Cart
*/
public function setOrder(?Order $order): Cart
{
$this->order = $order;
return $this;
}
public function getCarrier(): ?Carrier
{
return $this->carrier;
}
public function setCarrier(?Carrier $carrier): Cart
{
$this->carrier = $carrier;
return $this;
}
/**
* @return string
*/
public function getDeliveryOption(): string
{
return $this->deliveryOption;
}
/**
* @param string $deliveryOption
*
* @return Cart
*/
public function setDeliveryOption(string $deliveryOption): self
{
$this->deliveryOption = $deliveryOption;
return $this;
}
/**
* @return int
*/
public function getLanguageId(): int
{
return $this->LanguageId;
}
/**
* @param int $LanguageId
*
* @return Cart
*/
public function setLanguageId(int $LanguageId): self
{
$this->LanguageId = $LanguageId;
return $this;
}
public function getAddressDelivery(): ?Address
{
if ($this->addressDelivery && $this->addressDelivery->getId() === 0) {
return null;
}
return $this->addressDelivery;
}
public function setAddressDelivery(?Address $addressDelivery): Cart
{
$this->addressDelivery = $addressDelivery;
return $this;
}
/**
* @deprecated la dirección de facturación es la del cliente del carrito
*/
public function getAddressInvoice(): ?Address
{
if ($this->addressInvoice && $this->addressInvoice->getId() === 0) {
return null;
}
return $this->addressInvoice;
}
/**
* @deprecated la dirección de facturación es la del cliente del carrito
*/
public function setAddressInvoice(?Address $addressInvoice): Cart
{
$this->addressInvoice = $addressInvoice;
return $this;
}
/**
* @return int
*/
public function getCurrencyId(): int
{
return $this->currencyId;
}
/**
* @param int $currencyId
*
* @return Cart
*/
public function setCurrencyId(int $currencyId): self
{
$this->currencyId = $currencyId;
return $this;
}
public function getCustomer(): ?Customer
{
return $this->customer;
}
public function setCustomer(?Customer $customer): Cart
{
$this->customer = $customer;
return $this;
}
/**
* @return int
*/
public function getGuestId(): int
{
return $this->guestId;
}
/**
* @param int $guestId
*
* @return Cart
*/
public function setGuestId(int $guestId): self
{
$this->guestId = $guestId;
return $this;
}
/**
* @return string|null
*/
public function getSecureKey(): ?string
{
return $this->secureKey;
}
/**
* @param string|null $secureKey
*
* @return Cart
*/
public function setSecureKey(?string $secureKey): self
{
$this->secureKey = $secureKey;
return $this;
}
/**
* @return int
*/
public function getRecyclable(): int
{
return $this->recyclable;
}
/**
* @param int $recyclable
*
* @return Cart
*/
public function setRecyclable(int $recyclable): self
{
$this->recyclable = $recyclable;
return $this;
}
/**
* @return \DateTime
*/
public function getDateUpd(): \DateTime
{
return $this->dateUpd;
}
/**
* @param \DateTime $dateUpd
*
* @return Cart
*/
public function setDateUpd(\DateTime $dateUpd): self
{
$this->dateUpd = $dateUpd;
return $this;
}
/**
* @return \DateTime
*/
public function getDateAdd(): \DateTime
{
return $this->dateAdd;
}
/**
* @param \DateTime $dateAdd
*
* @return Cart
*/
public function setDateAdd(\DateTime $dateAdd): self
{
$this->dateAdd = $dateAdd;
return $this;
}
/**
* @return int
*/
public function getVirtual(): int
{
return $this->virtual;
}
/**
* @param int $virtual
*
* @return Cart
*/
public function setVirtual(int $virtual): self
{
$this->virtual = $virtual;
return $this;
}
/**
* @return bool
*/
public function getSync(): bool
{
return $this->sync;
}
/**
* @param bool $sync
*
* @return Cart
*/
public function setSync(bool $sync): self
{
$this->sync = $sync;
return $this;
}
/**
* @return int
*/
public function getSincronateShopConfigurationId(): int
{
return $this->sincronateShopConfigurationId;
}
/**
* @param int $sincronateShopConfigurationId
*
* @return Cart
*/
public function setSincronateShopConfigurationId(int $sincronateShopConfigurationId): self
{
$this->sincronateShopConfigurationId = $sincronateShopConfigurationId;
return $this;
}
/**
* @return int|null
*/
public function getMobile(): ?int
{
return $this->mobile;
}
/**
* @param int|null $mobile
*
* @return Cart
*/
public function setMobile(?int $mobile): self
{
$this->mobile = $mobile;
return $this;
}
/**
* @return int|null
*/
public function getDropshipping(): ?int
{
return $this->dropshipping;
}
/**
* @param int|null $dropshipping
*
* @return Cart
*/
public function setDropshipping(?int $dropshipping): self
{
$this->dropshipping = $dropshipping;
return $this;
}
/**
* @return string|null
*/
public function getPayment(): ?string
{
return $this->payment;
}
/**
* @param string|null $payment
*
* @return Cart
*/
public function setPayment(?string $payment): self
{
$this->payment = $payment;
return $this;
}
public function getPaymentMethodType(): ?string
{
return $this->paymentMethodType;
}
public function setPaymentMethodType(?string $paymentMethodType): Cart
{
$this->paymentMethodType = $paymentMethodType;
return $this;
}
public function getPaymentMethodId(): ?string
{
return $this->paymentMethodId;
}
public function setPaymentMethodId(?string $paymentMethodId): Cart
{
$this->paymentMethodId = $paymentMethodId;
return $this;
}
/**
* @return PaymentMethod|null
*/
public function getPackPaymentMethod(): ?PaymentMethod
{
return $this->packPaymentMethod;
}
/**
* @param PaymentMethod|null $packPaymentMethod
*
* @return Cart
*/
public function setPackPaymentMethod(?PaymentMethod $packPaymentMethod): Cart
{
$this->packPaymentMethod = $packPaymentMethod;
return $this;
}
/**
* @return string|null
*/
public function getPackStoredPaymentMethodId(): ?string
{
return $this->packStoredPaymentMethodId;
}
/**
* @param string|null $packStoredPaymentMethodId
*
* @return Cart
*/
public function setPackStoredPaymentMethodId(?string $packStoredPaymentMethodId): Cart
{
$this->packStoredPaymentMethodId = $packStoredPaymentMethodId;
return $this;
}
/**
* @return PaymentMethod|null
*/
public function getServicesPaymentMethod(): ?PaymentMethod
{
return $this->servicesPaymentMethod;
}
/**
* @param PaymentMethod|null $servicesPaymentMethod
*
* @return Cart
*/
public function setServicesPaymentMethod(?PaymentMethod $servicesPaymentMethod): Cart
{
$this->servicesPaymentMethod = $servicesPaymentMethod;
return $this;
}
/**
* @return string|null
*/
public function getServicesStoredPaymentMethodId(): ?string
{
return $this->servicesStoredPaymentMethodId;
}
/**
* @param string|null $servicesStoredPaymentMethodId
*
* @return Cart
*/
public function setServicesStoredPaymentMethodId(?string $servicesStoredPaymentMethodId): Cart
{
$this->servicesStoredPaymentMethodId = $servicesStoredPaymentMethodId;
return $this;
}
/**
* @return float|null
*/
public function getTotalProducts(): ?float
{
return $this->totalProducts;
}
/**
* @param float|null $totalProducts
*
* @return Cart
*/
public function setTotalProducts(?float $totalProducts): self
{
$this->totalProducts = $totalProducts;
return $this;
}
/**
* @return float|null
*/
public function getTotalShipping(): ?float
{
return $this->totalShipping;
}
/**
* @param float|null $totalShipping
*
* @return Cart
*/
public function setTotalShipping(?float $totalShipping): self
{
$this->totalShipping = $totalShipping;
return $this;
}
/**
* @param array<CartProduct>|ArrayCollection<int, CartProduct> $cartProducts
*
* @return $this
*/
public function setCartProducts($cartProducts): Cart
{
$this->cartProducts = $cartProducts;
return $this;
}
public function addCartProduct(CartProduct $cartProduct): Cart
{
if (!$this->cartProducts->contains($cartProduct)) {
$this->cartProducts[] = $cartProduct;
$cartProduct->setCart($this);
}
return $this;
}
public function removeCartProduct(CartProduct $cartProduct): Cart
{
if ($this->cartProducts->contains($cartProduct)) {
$this->cartProducts->removeElement($cartProduct);
}
return $this;
}
/**
* @param CartProduct[] $cartProducts
*/
public function addCartProducts(array $cartProducts): void
{
foreach ($cartProducts as $cartProduct) {
$this->cartProducts->add($cartProduct);
}
}
/**
* @return CartProduct[]|Collection<int, CartProduct>
*/
public function getCartProducts()
{
return $this->cartProducts;
}
public function getCarrierComment(): ?string
{
return $this->carrierComment;
}
public function setCarrierComment(?string $carrierComment): Cart
{
$this->carrierComment = $carrierComment;
return $this;
}
public function getRefOrderSupplier(): ?string
{
return $this->refOrderSupplier;
}
public function setRefOrderSupplier(?string $refOrderSupplier): Cart
{
$this->refOrderSupplier = $refOrderSupplier;
return $this;
}
public function isSystem(): bool
{
return $this->system;
}
public function setSystem(bool $system): Cart
{
$this->system = $system;
return $this;
}
public function getSellingChannel(): ?string
{
return $this->sellingChannel;
}
public function setSellingChannel(?string $sellingChannel): Cart
{
$this->sellingChannel = $sellingChannel;
return $this;
}
public function getAdditionalParameters(): ?string
{
return $this->additionalParameters;
}
public function setAdditionalParameters(?string $additionalParameters): Cart
{
$this->additionalParameters = $additionalParameters;
return $this;
}
public function getDateAmazon(): ?\DateTime
{
return $this->dateAmazon;
}
public function setDateAmazon(?\DateTime $dateAmazon): Cart
{
$this->dateAmazon = $dateAmazon;
return $this;
}
public function isFba(): bool
{
return $this->fba;
}
public function setFba(bool $fba): Cart
{
$this->fba = $fba;
return $this;
}
public function getMaxDeliveryDatetime(): ?\DateTime
{
return $this->maxDeliveryDatetime;
}
public function setMaxDeliveryDatetime(?\DateTime $maxDeliveryDatetime): Cart
{
$this->maxDeliveryDatetime = $maxDeliveryDatetime;
return $this;
}
public function getMaxExpeditionDatetime(): ?\DateTime
{
return $this->maxExpeditionDatetime;
}
public function setMaxExpeditionDatetime(?\DateTime $maxExpeditionDatetime): Cart
{
$this->maxExpeditionDatetime = $maxExpeditionDatetime;
return $this;
}
public function getCodeDiscount(): ?CodeDiscount
{
if ($this->codeDiscount && $this->codeDiscount->getId() === 0) {
return null;
}
return $this->codeDiscount;
}
public function setCodeDiscount(?CodeDiscount $codeDiscount): Cart
{
$this->codeDiscount = $codeDiscount;
return $this;
}
public function getShipmentChoices(): ?string
{
return $this->shipmentChoices;
}
public function setShipmentChoices(?string $shipmentChoices): Cart
{
$this->shipmentChoices = $shipmentChoices;
return $this;
}
public function getCartParent(): ?Cart
{
return $this->cartParent;
}
public function setCartParent(?Cart $cartParent): Cart
{
$this->cartParent = $cartParent;
return $this;
}
/**
* @return Collection<int, Cart>
*/
public function getCartChildren(): Collection
{
return $this->cartChildren;
}
public function addCart(Cart $cart): Cart
{
if (!$this->cartChildren->contains($cart)) {
$this->cartChildren[] = $cart;
$cart->setCartParent($this);
}
return $this;
}
public function getLogisticWeight(): ?float
{
return $this->logisticWeight;
}
public function setLogisticWeight(?float $logisticWeight): void
{
$this->logisticWeight = $logisticWeight;
}
}