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