src/Entity/System/Cart.php line 26

Open in your IDE?
  1. <?php
  2. namespace App\Entity\System;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. /**
  7. * Cart
  8. *
  9. * @ORM\Table(
  10. * name="ps_cart",
  11. * indexes={
  12. *
  13. * @ORM\Index(name="is_sync", columns={"is_sync"}),
  14. * @ORM\Index(name="is_virtual", columns={"is_virtual"}),
  15. * @ORM\Index(name="id_currency", columns={"id_currency"}),
  16. * @ORM\Index(name="secure_key", columns={"secure_key"}),
  17. * @ORM\Index(name="delivery_option", columns={"delivery_option"})
  18. * }
  19. * )
  20. *
  21. * @ORM\Entity(repositoryClass="App\Repository\System\CartRepository")
  22. */
  23. class Cart
  24. {
  25. public const DEFAULT_CURRENCY_EUR = 1;
  26. public const string SERVICES_REFERENCE_PREFIX = 'Serv_cart_';
  27. /**
  28. * @var int
  29. *
  30. * @ORM\Id
  31. *
  32. * @ORM\GeneratedValue(strategy="AUTO")
  33. *
  34. * @ORM\Column(type="integer", name="id_cart")
  35. */
  36. private $id;
  37. /**
  38. * One Cart has One Order.
  39. *
  40. * @var Order|null
  41. *
  42. * @ORM\OneToOne(targetEntity="App\Entity\System\Order", mappedBy="cart")
  43. */
  44. private $order;
  45. /**
  46. * @ORM\ManyToOne(targetEntity="App\Entity\System\Carrier")
  47. *
  48. * @ORM\JoinColumn(name="id_carrier", referencedColumnName="id_carrier", nullable=true)
  49. */
  50. private ?Carrier $carrier;
  51. /**
  52. * @var string
  53. *
  54. * @ORM\Column(type="string", length=1000)
  55. */
  56. private $deliveryOption;
  57. /**
  58. * @ORM\ManyToOne(targetEntity="App\Entity\System\Address")
  59. *
  60. * @ORM\JoinColumn(referencedColumnName="id_address", name="id_address_delivery", nullable=true)
  61. */
  62. private ?Address $addressDelivery;
  63. /**
  64. * @var int
  65. *
  66. * @ORM\Column(type="integer", length=10, name="id_currency")
  67. */
  68. private $currencyId;
  69. /**
  70. * @ORM\ManyToOne(targetEntity="App\Entity\System\Customer")
  71. *
  72. * @ORM\JoinColumn(name="id_customer", referencedColumnName="id_customer", nullable=false)
  73. */
  74. private Customer $customer;
  75. /**
  76. * @var string|null
  77. *
  78. * @ORM\Column(type="string", length=32, nullable=true, options={"default" : "-1"})
  79. */
  80. private $secureKey;
  81. /**
  82. * @var bool
  83. *
  84. * @ORM\Column(type="boolean", options={"default" : 1})
  85. */
  86. private $recyclable;
  87. /**
  88. * @var \DateTime
  89. *
  90. * @ORM\Column(type="datetime")
  91. */
  92. private $dateUpd;
  93. /**
  94. * @var \DateTime
  95. *
  96. * @ORM\Column(type="datetime")
  97. */
  98. private $dateAdd;
  99. /**
  100. * @var bool
  101. *
  102. * @ORM\Column(type="boolean", options={"default" : 0}, name="is_virtual")
  103. */
  104. private $virtual;
  105. /**
  106. * @var bool
  107. *
  108. * @ORM\Column(type="boolean", options={"default" : 0}, name="is_sync")
  109. */
  110. private bool $sync;
  111. /**
  112. * @var bool
  113. *
  114. * @ORM\Column(type="boolean", options={"default" : 0}, name="is_mobile")
  115. */
  116. private $mobile;
  117. /**
  118. * @var bool
  119. *
  120. * @ORM\Column(type="boolean", options={"default" : 0})
  121. */
  122. private $dropshipping;
  123. /**
  124. * @var float|null
  125. *
  126. * @ORM\Column(type="float", options={"default" : 0.00}, nullable=true)
  127. */
  128. private $totalProducts;
  129. /**
  130. * @var float|null
  131. *
  132. * @ORM\Column(type="float", options={"default" : 0.00}, nullable=true, name="total_envio")
  133. */
  134. private $totalShipping;
  135. /**
  136. * @ORM\Column(type="float", nullable=true, name="logistic_weight")
  137. */
  138. private ?float $logisticWeight;
  139. /**
  140. * @var ArrayCollection<int, CartProduct>&iterable<CartProduct>
  141. *
  142. * @ORM\OneToMany(targetEntity="CartProduct", mappedBy="cart", cascade={"persist", "remove"})
  143. */
  144. private $cartProducts;
  145. /**
  146. * @ORM\Column(type="string", length=50, nullable=true)
  147. */
  148. private ?string $refOrderSupplier = null;
  149. /**
  150. * @ORM\Column(type="boolean", options={"default" : 0}, name="is_system")
  151. */
  152. private bool $system = false;
  153. /**
  154. * @ORM\Column(type="string", length=64, nullable=true)
  155. */
  156. private ?string $sellingChannel = null;
  157. /**
  158. * @ORM\Column(type="string", length=256, nullable=true)
  159. */
  160. private ?string $additionalParameters = null;
  161. /**
  162. * @ORM\Column(type="datetime", nullable=true)
  163. */
  164. private ?\DateTime $dateAmazon = null;
  165. /**
  166. * @ORM\Column(type="boolean", options={"default" : 0})
  167. */
  168. private bool $fba = false;
  169. /**
  170. * @ORM\Column(type="datetime", nullable=true)
  171. */
  172. private ?\DateTime $maxDeliveryDatetime = null;
  173. /**
  174. * @ORM\Column(type="datetime", nullable=true)
  175. */
  176. private ?\DateTime $maxExpeditionDatetime = null;
  177. /**
  178. * @ORM\Column(type="text", nullable=true)
  179. */
  180. private ?string $shipmentChoices = null;
  181. /**
  182. * @ORM\ManyToOne(targetEntity="App\Entity\System\CodeDiscount")
  183. *
  184. * @ORM\JoinColumn(name="code_discount_id", referencedColumnName="id", nullable=true, onDelete="SET NULL")
  185. */
  186. private ?CodeDiscount $codeDiscount = null;
  187. /**
  188. * @ORM\ManyToOne(targetEntity="App\Entity\System\Cart", inversedBy="cartChildren")
  189. *
  190. * @ORM\JoinColumn(name="cart_parent_id", referencedColumnName="id_cart", nullable=true)
  191. */
  192. private ?Cart $cartParent = null;
  193. /**
  194. * @var Collection<int, Cart>&iterable<Cart>
  195. *
  196. * @ORM\OneToMany(targetEntity="App\Entity\System\Cart", mappedBy="cartParent")
  197. */
  198. private $cartChildren;
  199. /**
  200. * @ORM\ManyToOne(targetEntity="App\Entity\System\PaymentMethod")
  201. *
  202. * @ORM\JoinColumn(name="payment_method", referencedColumnName="id_payment_method", nullable=true)
  203. */
  204. private ?PaymentMethod $paymentMethod = null;
  205. /**
  206. * @ORM\Column(type="string", length=64, nullable=true)
  207. */
  208. private ?string $shipFromAddressCompanyName = null;
  209. public function __construct()
  210. {
  211. $this->currencyId = self::DEFAULT_CURRENCY_EUR;
  212. $this->recyclable = false;
  213. $this->sync = false;
  214. $this->logisticWeight = 0;
  215. $this->cartProducts = new ArrayCollection();
  216. $this->cartChildren = new ArrayCollection();
  217. $this->dropshipping = false;
  218. $this->mobile = false;
  219. $this->shipFromAddressCompanyName = null;
  220. }
  221. /**
  222. * @return int
  223. */
  224. public function getId(): int
  225. {
  226. return $this->id;
  227. }
  228. /**
  229. * @param int|null $id
  230. *
  231. * @return Cart
  232. */
  233. public function setIdCart(?int $id): Cart
  234. {
  235. $this->id = $id;
  236. return $this;
  237. }
  238. /**
  239. * @return Order|null
  240. */
  241. public function getOrder(): ?Order
  242. {
  243. if ($this->order && $this->order->getId() === 0) {
  244. return null;
  245. }
  246. return $this->order;
  247. }
  248. /**
  249. * @param Order|null $order
  250. *
  251. * @return Cart
  252. */
  253. public function setOrder(?Order $order): Cart
  254. {
  255. $this->order = $order;
  256. return $this;
  257. }
  258. public function getCarrier(): ?Carrier
  259. {
  260. return $this->carrier;
  261. }
  262. public function setCarrier(?Carrier $carrier): Cart
  263. {
  264. $this->carrier = $carrier;
  265. return $this;
  266. }
  267. /**
  268. * @return string
  269. */
  270. public function getDeliveryOption(): string
  271. {
  272. return $this->deliveryOption;
  273. }
  274. /**
  275. * @param string $deliveryOption
  276. *
  277. * @return Cart
  278. */
  279. public function setDeliveryOption(string $deliveryOption): self
  280. {
  281. $this->deliveryOption = $deliveryOption;
  282. return $this;
  283. }
  284. public function getAddressDelivery(): ?Address
  285. {
  286. if ($this->addressDelivery && $this->addressDelivery->getId() === 0) {
  287. return null;
  288. }
  289. return $this->addressDelivery;
  290. }
  291. public function setAddressDelivery(?Address $addressDelivery): Cart
  292. {
  293. $this->addressDelivery = $addressDelivery;
  294. return $this;
  295. }
  296. /**
  297. * @return int
  298. */
  299. public function getCurrencyId(): int
  300. {
  301. return $this->currencyId;
  302. }
  303. /**
  304. * @param int $currencyId
  305. *
  306. * @return Cart
  307. */
  308. public function setCurrencyId(int $currencyId): self
  309. {
  310. $this->currencyId = $currencyId;
  311. return $this;
  312. }
  313. public function getCustomer(): Customer
  314. {
  315. return $this->customer;
  316. }
  317. public function setCustomer(Customer $customer): Cart
  318. {
  319. $this->customer = $customer;
  320. return $this;
  321. }
  322. /**
  323. * @return string|null
  324. */
  325. public function getSecureKey(): ?string
  326. {
  327. return $this->secureKey;
  328. }
  329. /**
  330. * @param string|null $secureKey
  331. *
  332. * @return Cart
  333. */
  334. public function setSecureKey(?string $secureKey): self
  335. {
  336. $this->secureKey = $secureKey;
  337. return $this;
  338. }
  339. public function isRecyclable(): bool
  340. {
  341. return $this->recyclable;
  342. }
  343. public function setRecyclable(bool $recyclable): self
  344. {
  345. $this->recyclable = $recyclable;
  346. return $this;
  347. }
  348. /**
  349. * @return \DateTime
  350. */
  351. public function getDateUpd(): \DateTime
  352. {
  353. return $this->dateUpd;
  354. }
  355. /**
  356. * @param \DateTime $dateUpd
  357. *
  358. * @return Cart
  359. */
  360. public function setDateUpd(\DateTime $dateUpd): self
  361. {
  362. $this->dateUpd = $dateUpd;
  363. return $this;
  364. }
  365. /**
  366. * @return \DateTime
  367. */
  368. public function getDateAdd(): \DateTime
  369. {
  370. return $this->dateAdd;
  371. }
  372. /**
  373. * @param \DateTime $dateAdd
  374. *
  375. * @return Cart
  376. */
  377. public function setDateAdd(\DateTime $dateAdd): self
  378. {
  379. $this->dateAdd = $dateAdd;
  380. return $this;
  381. }
  382. public function isVirtual(): bool
  383. {
  384. return $this->virtual;
  385. }
  386. public function setVirtual(bool $virtual): self
  387. {
  388. $this->virtual = $virtual;
  389. return $this;
  390. }
  391. public function getSync(): bool
  392. {
  393. return $this->sync;
  394. }
  395. /**
  396. * @param bool $sync
  397. *
  398. * @return Cart
  399. */
  400. public function setSync(bool $sync): self
  401. {
  402. $this->sync = $sync;
  403. return $this;
  404. }
  405. public function isMobile(): bool
  406. {
  407. return $this->mobile;
  408. }
  409. public function setMobile(bool $mobile): self
  410. {
  411. $this->mobile = $mobile;
  412. return $this;
  413. }
  414. public function isDropshipping(): bool
  415. {
  416. return $this->dropshipping;
  417. }
  418. public function setDropshipping(bool $dropshipping): self
  419. {
  420. $this->dropshipping = $dropshipping;
  421. return $this;
  422. }
  423. public function getTotalProducts(): ?float
  424. {
  425. return $this->totalProducts;
  426. }
  427. public function setTotalProducts(?float $totalProducts): self
  428. {
  429. $this->totalProducts = $totalProducts;
  430. return $this;
  431. }
  432. public function getTotalShipping(): ?float
  433. {
  434. return $this->totalShipping;
  435. }
  436. public function setTotalShipping(?float $totalShipping): self
  437. {
  438. $this->totalShipping = $totalShipping;
  439. return $this;
  440. }
  441. /**
  442. * @param ArrayCollection<int, CartProduct>&iterable<CartProduct> $cartProducts
  443. *
  444. * @return $this
  445. */
  446. public function setCartProducts($cartProducts): Cart
  447. {
  448. $this->cartProducts = $cartProducts;
  449. return $this;
  450. }
  451. public function addCartProduct(CartProduct $cartProduct): Cart
  452. {
  453. if (!$this->cartProducts->contains($cartProduct)) {
  454. $this->cartProducts[] = $cartProduct;
  455. $cartProduct->setCart($this);
  456. }
  457. return $this;
  458. }
  459. public function removeCartProduct(CartProduct $cartProduct): Cart
  460. {
  461. if ($this->cartProducts->contains($cartProduct)) {
  462. $this->cartProducts->removeElement($cartProduct);
  463. }
  464. return $this;
  465. }
  466. /**
  467. * @param CartProduct[] $cartProducts
  468. */
  469. public function addCartProducts(array $cartProducts): void
  470. {
  471. foreach ($cartProducts as $cartProduct) {
  472. $this->cartProducts->add($cartProduct);
  473. }
  474. }
  475. /**
  476. * @return ArrayCollection<int, CartProduct>&iterable<CartProduct>
  477. */
  478. public function getCartProducts()
  479. {
  480. return $this->cartProducts;
  481. }
  482. public function getRefOrderSupplier(): ?string
  483. {
  484. return $this->refOrderSupplier;
  485. }
  486. public function setRefOrderSupplier(?string $refOrderSupplier): Cart
  487. {
  488. $this->refOrderSupplier = $refOrderSupplier;
  489. return $this;
  490. }
  491. public function isSystem(): bool
  492. {
  493. return $this->system;
  494. }
  495. public function setSystem(bool $system): Cart
  496. {
  497. $this->system = $system;
  498. return $this;
  499. }
  500. public function getSellingChannel(): ?string
  501. {
  502. return $this->sellingChannel;
  503. }
  504. public function setSellingChannel(?string $sellingChannel): Cart
  505. {
  506. $this->sellingChannel = $sellingChannel;
  507. return $this;
  508. }
  509. public function getAdditionalParameters(): ?string
  510. {
  511. return $this->additionalParameters;
  512. }
  513. public function setAdditionalParameters(?string $additionalParameters): Cart
  514. {
  515. $this->additionalParameters = $additionalParameters;
  516. return $this;
  517. }
  518. public function getDateAmazon(): ?\DateTime
  519. {
  520. return $this->dateAmazon;
  521. }
  522. public function setDateAmazon(?\DateTime $dateAmazon): Cart
  523. {
  524. $this->dateAmazon = $dateAmazon;
  525. return $this;
  526. }
  527. public function isFba(): bool
  528. {
  529. return $this->fba;
  530. }
  531. public function setFba(bool $fba): Cart
  532. {
  533. $this->fba = $fba;
  534. return $this;
  535. }
  536. public function getMaxDeliveryDatetime(): ?\DateTime
  537. {
  538. return $this->maxDeliveryDatetime;
  539. }
  540. public function setMaxDeliveryDatetime(?\DateTime $maxDeliveryDatetime): Cart
  541. {
  542. $this->maxDeliveryDatetime = $maxDeliveryDatetime;
  543. return $this;
  544. }
  545. public function getMaxExpeditionDatetime(): ?\DateTime
  546. {
  547. return $this->maxExpeditionDatetime;
  548. }
  549. public function setMaxExpeditionDatetime(?\DateTime $maxExpeditionDatetime): Cart
  550. {
  551. $this->maxExpeditionDatetime = $maxExpeditionDatetime;
  552. return $this;
  553. }
  554. public function getCodeDiscount(): ?CodeDiscount
  555. {
  556. if ($this->codeDiscount && $this->codeDiscount->getId() === 0) {
  557. return null;
  558. }
  559. return $this->codeDiscount;
  560. }
  561. public function setCodeDiscount(?CodeDiscount $codeDiscount): Cart
  562. {
  563. $this->codeDiscount = $codeDiscount;
  564. return $this;
  565. }
  566. public function getShipmentChoices(): ?string
  567. {
  568. return $this->shipmentChoices;
  569. }
  570. public function setShipmentChoices(?string $shipmentChoices): Cart
  571. {
  572. $this->shipmentChoices = $shipmentChoices;
  573. return $this;
  574. }
  575. public function getCartParent(): ?Cart
  576. {
  577. return $this->cartParent;
  578. }
  579. public function setCartParent(?Cart $cartParent): Cart
  580. {
  581. $this->cartParent = $cartParent;
  582. return $this;
  583. }
  584. /**
  585. * @return Collection<int, Cart>&iterable<Cart>
  586. */
  587. public function getCartChildren()
  588. {
  589. return $this->cartChildren;
  590. }
  591. public function addCart(Cart $cart): Cart
  592. {
  593. if (!$this->cartChildren->contains($cart)) {
  594. $this->cartChildren[] = $cart;
  595. $cart->setCartParent($this);
  596. }
  597. return $this;
  598. }
  599. public function getLogisticWeight(): ?float
  600. {
  601. return $this->logisticWeight;
  602. }
  603. public function setLogisticWeight(?float $logisticWeight): void
  604. {
  605. $this->logisticWeight = $logisticWeight;
  606. }
  607. public function getPaymentMethod(): ?PaymentMethod
  608. {
  609. return $this->paymentMethod;
  610. }
  611. public function setPaymentMethod(?PaymentMethod $paymentMethod): Cart
  612. {
  613. $this->paymentMethod = $paymentMethod;
  614. return $this;
  615. }
  616. public function getShipFromAddressCompanyName(): ?string
  617. {
  618. return $this->shipFromAddressCompanyName;
  619. }
  620. public function setShipFromAddressCompanyName(?string $shipFromAddressCompanyName): void
  621. {
  622. $this->shipFromAddressCompanyName = $shipFromAddressCompanyName;
  623. }
  624. }