Totals.php 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Quote\Model\Cart;
  7. use Magento\Quote\Api\Data\TotalsInterface;
  8. use Magento\Framework\Model\AbstractExtensibleModel;
  9. /**
  10. * Cart Totals
  11. *
  12. * @SuppressWarnings(PHPMD.ExcessivePublicCount)
  13. * @codeCoverageIgnore
  14. */
  15. class Totals extends AbstractExtensibleModel implements TotalsInterface
  16. {
  17. /**
  18. * Get grand total in quote currency
  19. *
  20. * @return float|null
  21. */
  22. public function getGrandTotal()
  23. {
  24. return $this->getData(self::KEY_GRAND_TOTAL);
  25. }
  26. /**
  27. * Set grand total in quote currency
  28. *
  29. * @param float $grandTotal
  30. * @return $this
  31. */
  32. public function setGrandTotal($grandTotal)
  33. {
  34. return $this->setData(self::KEY_GRAND_TOTAL, $grandTotal);
  35. }
  36. /**
  37. * Get grand total in base currency
  38. *
  39. * @return float|null
  40. */
  41. public function getBaseGrandTotal()
  42. {
  43. return $this->getData(self::KEY_BASE_GRAND_TOTAL);
  44. }
  45. /**
  46. * Set grand total in base currency
  47. *
  48. * @param float $baseGrandTotal
  49. * @return $this
  50. */
  51. public function setBaseGrandTotal($baseGrandTotal)
  52. {
  53. return $this->setData(self::KEY_BASE_GRAND_TOTAL, $baseGrandTotal);
  54. }
  55. /**
  56. * Get subtotal in quote currency
  57. *
  58. * @return float|null
  59. */
  60. public function getSubtotal()
  61. {
  62. return $this->getData(self::KEY_SUBTOTAL);
  63. }
  64. /**
  65. * Set subtotal in quote currency
  66. *
  67. * @param float $subtotal
  68. * @return $this
  69. */
  70. public function setSubtotal($subtotal)
  71. {
  72. return $this->setData(self::KEY_SUBTOTAL, $subtotal);
  73. }
  74. /**
  75. * Get subtotal in base currency
  76. *
  77. * @return float|null
  78. */
  79. public function getBaseSubtotal()
  80. {
  81. return $this->getData(self::KEY_BASE_SUBTOTAL);
  82. }
  83. /**
  84. * Set subtotal in base currency
  85. *
  86. * @param float $baseSubtotal
  87. * @return $this
  88. */
  89. public function setBaseSubtotal($baseSubtotal)
  90. {
  91. return $this->setData(self::KEY_BASE_SUBTOTAL, $baseSubtotal);
  92. }
  93. /**
  94. * Get discount amount in quote currency
  95. *
  96. * @return float|null
  97. */
  98. public function getDiscountAmount()
  99. {
  100. return $this->getData(self::KEY_DISCOUNT_AMOUNT);
  101. }
  102. /**
  103. * Set discount amount in quote currency
  104. *
  105. * @param float $discountAmount
  106. * @return $this
  107. */
  108. public function setDiscountAmount($discountAmount)
  109. {
  110. return $this->setData(self::KEY_DISCOUNT_AMOUNT, $discountAmount);
  111. }
  112. /**
  113. * Get discount amount in base currency
  114. *
  115. * @return float|null
  116. */
  117. public function getBaseDiscountAmount()
  118. {
  119. return $this->getData(self::KEY_BASE_DISCOUNT_AMOUNT);
  120. }
  121. /**
  122. * Set discount amount in base currency
  123. *
  124. * @param float $baseDiscountAmount
  125. * @return $this
  126. */
  127. public function setBaseDiscountAmount($baseDiscountAmount)
  128. {
  129. return $this->setData(self::KEY_BASE_DISCOUNT_AMOUNT, $baseDiscountAmount);
  130. }
  131. /**
  132. * Get subtotal in quote currency with applied discount
  133. *
  134. * @return float|null
  135. */
  136. public function getSubtotalWithDiscount()
  137. {
  138. return $this->getData(self::KEY_SUBTOTAL_WITH_DISCOUNT);
  139. }
  140. /**
  141. * Set subtotal in quote currency with applied discount
  142. *
  143. * @param float $subtotalWithDiscount
  144. * @return $this
  145. */
  146. public function setSubtotalWithDiscount($subtotalWithDiscount)
  147. {
  148. return $this->setData(self::KEY_SUBTOTAL_WITH_DISCOUNT, $subtotalWithDiscount);
  149. }
  150. /**
  151. * Get subtotal in base currency with applied discount
  152. *
  153. * @return float|null
  154. */
  155. public function getBaseSubtotalWithDiscount()
  156. {
  157. return $this->getData(self::KEY_BASE_SUBTOTAL_WITH_DISCOUNT);
  158. }
  159. /**
  160. * Set subtotal in base currency with applied discount
  161. *
  162. * @param float $baseSubtotalWithDiscount
  163. * @return $this
  164. */
  165. public function setBaseSubtotalWithDiscount($baseSubtotalWithDiscount)
  166. {
  167. return $this->setData(self::KEY_BASE_SUBTOTAL_WITH_DISCOUNT, $baseSubtotalWithDiscount);
  168. }
  169. /**
  170. * Get shipping amount in quote currency
  171. *
  172. * @return float|null
  173. */
  174. public function getShippingAmount()
  175. {
  176. return $this->getData(self::KEY_SHIPPING_AMOUNT);
  177. }
  178. /**
  179. * Set shipping amount in quote currency
  180. *
  181. * @param float $shippingAmount
  182. * @return $this
  183. */
  184. public function setShippingAmount($shippingAmount)
  185. {
  186. return $this->setData(self::KEY_SHIPPING_AMOUNT, $shippingAmount);
  187. }
  188. /**
  189. * Get shipping amount in base currency
  190. *
  191. * @return float|null
  192. */
  193. public function getBaseShippingAmount()
  194. {
  195. return $this->getData(self::KEY_BASE_SHIPPING_AMOUNT);
  196. }
  197. /**
  198. * Set shipping amount in base currency
  199. *
  200. * @param float $baseShippingAmount
  201. * @return $this
  202. */
  203. public function setBaseShippingAmount($baseShippingAmount)
  204. {
  205. return $this->setData(self::KEY_BASE_SHIPPING_AMOUNT, $baseShippingAmount);
  206. }
  207. /**
  208. * Get shipping discount amount in quote currency
  209. *
  210. * @return float|null
  211. */
  212. public function getShippingDiscountAmount()
  213. {
  214. return $this->getData(self::KEY_SHIPPING_DISCOUNT_AMOUNT);
  215. }
  216. /**
  217. * Set shipping discount amount in quote currency
  218. *
  219. * @param float $shippingDiscountAmount
  220. * @return $this
  221. */
  222. public function setShippingDiscountAmount($shippingDiscountAmount)
  223. {
  224. return $this->setData(self::KEY_SHIPPING_DISCOUNT_AMOUNT, $shippingDiscountAmount);
  225. }
  226. /**
  227. * Get shipping discount amount in base currency
  228. *
  229. * @return float|null
  230. */
  231. public function getBaseShippingDiscountAmount()
  232. {
  233. return $this->getData(self::KEY_BASE_SHIPPING_DISCOUNT_AMOUNT);
  234. }
  235. /**
  236. * Set shipping discount amount in base currency
  237. *
  238. * @param float $baseShippingDiscountAmount
  239. * @return $this
  240. */
  241. public function setBaseShippingDiscountAmount($baseShippingDiscountAmount)
  242. {
  243. return $this->setData(self::KEY_BASE_SHIPPING_DISCOUNT_AMOUNT, $baseShippingDiscountAmount);
  244. }
  245. /**
  246. * Get tax amount in quote currency
  247. *
  248. * @return float|null
  249. */
  250. public function getTaxAmount()
  251. {
  252. return $this->getData(self::KEY_TAX_AMOUNT);
  253. }
  254. /**
  255. * Set tax amount in quote currency
  256. *
  257. * @param float $taxAmount
  258. * @return $this
  259. */
  260. public function setTaxAmount($taxAmount)
  261. {
  262. return $this->setData(self::KEY_TAX_AMOUNT, $taxAmount);
  263. }
  264. /**
  265. * Get tax amount in base currency
  266. *
  267. * @return float|null
  268. */
  269. public function getBaseTaxAmount()
  270. {
  271. return $this->getData(self::KEY_BASE_TAX_AMOUNT);
  272. }
  273. /**
  274. * Set tax amount in base currency
  275. *
  276. * @param float $baseTaxAmount
  277. * @return $this
  278. */
  279. public function setBaseTaxAmount($baseTaxAmount)
  280. {
  281. return $this->setData(self::KEY_BASE_TAX_AMOUNT, $baseTaxAmount);
  282. }
  283. /**
  284. * Returns the total weee tax applied amount in quote currency.
  285. *
  286. * @return float Item weee tax applied amount in quote currency.
  287. */
  288. public function getWeeeTaxAppliedAmount()
  289. {
  290. return $this->getData(self::KEY_WEEE_TAX_APPLIED_AMOUNT);
  291. }
  292. /**
  293. * Sets the total weee tax applied amount in quote currency.
  294. *
  295. * @param float $weeeTaxAppliedAmount
  296. * @return $this
  297. */
  298. public function setWeeeTaxAppliedAmount($weeeTaxAppliedAmount)
  299. {
  300. return $this->setData(self::KEY_WEEE_TAX_APPLIED_AMOUNT, $weeeTaxAppliedAmount);
  301. }
  302. /**
  303. * Get shipping tax amount in quote currency
  304. *
  305. * @return float|null
  306. */
  307. public function getShippingTaxAmount()
  308. {
  309. return $this->getData(self::KEY_SHIPPING_TAX_AMOUNT);
  310. }
  311. /**
  312. * Set shipping tax amount in quote currency
  313. *
  314. * @param float $shippingTaxAmount
  315. * @return $this
  316. */
  317. public function setShippingTaxAmount($shippingTaxAmount)
  318. {
  319. return $this->setData(self::KEY_SHIPPING_TAX_AMOUNT, $shippingTaxAmount);
  320. }
  321. /**
  322. * Get shipping tax amount in base currency
  323. *
  324. * @return float|null
  325. */
  326. public function getBaseShippingTaxAmount()
  327. {
  328. return $this->getData(self::KEY_BASE_SHIPPING_TAX_AMOUNT);
  329. }
  330. /**
  331. * Set shipping tax amount in base currency
  332. *
  333. * @param float $baseShippingTaxAmount
  334. * @return $this
  335. */
  336. public function setBaseShippingTaxAmount($baseShippingTaxAmount)
  337. {
  338. return $this->setData(self::KEY_BASE_SHIPPING_TAX_AMOUNT, $baseShippingTaxAmount);
  339. }
  340. /**
  341. * Get subtotal including tax in quote currency
  342. *
  343. * @return float|null
  344. */
  345. public function getSubtotalInclTax()
  346. {
  347. return $this->getData(self::KEY_SUBTOTAL_INCL_TAX);
  348. }
  349. /**
  350. * Set subtotal including tax in quote currency
  351. *
  352. * @param float $subtotalInclTax
  353. * @return $this
  354. */
  355. public function setSubtotalInclTax($subtotalInclTax)
  356. {
  357. return $this->setData(self::KEY_SUBTOTAL_INCL_TAX, $subtotalInclTax);
  358. }
  359. /**
  360. * Get subtotal including tax in base currency
  361. *
  362. * @return float|null
  363. */
  364. public function getBaseSubtotalInclTax()
  365. {
  366. return $this->getData(self::KEY_BASE_SUBTOTAL_INCL_TAX);
  367. }
  368. /**
  369. * Set subtotal including tax in base currency
  370. *
  371. * @param float $baseSubtotalInclTax
  372. * @return $this
  373. */
  374. public function setBaseSubtotalInclTax($baseSubtotalInclTax)
  375. {
  376. return $this->setData(self::KEY_BASE_SUBTOTAL_INCL_TAX, $baseSubtotalInclTax);
  377. }
  378. /**
  379. * Get shipping including tax in quote currency
  380. *
  381. * @return float|null
  382. */
  383. public function getShippingInclTax()
  384. {
  385. return $this->getData(self::KEY_SHIPPING_INCL_TAX);
  386. }
  387. /**
  388. * Set shipping including tax in quote currency
  389. *
  390. * @param float $shippingInclTax
  391. * @return $this
  392. */
  393. public function setShippingInclTax($shippingInclTax)
  394. {
  395. return $this->setData(self::KEY_SHIPPING_INCL_TAX, $shippingInclTax);
  396. }
  397. /**
  398. * Get shipping including tax in base currency
  399. *
  400. * @return float|null
  401. */
  402. public function getBaseShippingInclTax()
  403. {
  404. return $this->getData(self::KEY_BASE_SHIPPING_INCL_TAX);
  405. }
  406. /**
  407. * Set shipping including tax in base currency
  408. *
  409. * @param float $baseShippingInclTax
  410. * @return $this
  411. */
  412. public function setBaseShippingInclTax($baseShippingInclTax)
  413. {
  414. return $this->setData(self::KEY_BASE_SHIPPING_INCL_TAX, $baseShippingInclTax);
  415. }
  416. /**
  417. * Get base currency code
  418. *
  419. * @return string|null
  420. */
  421. public function getBaseCurrencyCode()
  422. {
  423. return $this->getData(self::KEY_BASE_CURRENCY_CODE);
  424. }
  425. /**
  426. * Set base currency code
  427. *
  428. * @param string $baseCurrencyCode
  429. * @return $this
  430. */
  431. public function setBaseCurrencyCode($baseCurrencyCode)
  432. {
  433. return $this->setData(self::KEY_BASE_CURRENCY_CODE, $baseCurrencyCode);
  434. }
  435. /**
  436. * Get quote currency code
  437. *
  438. * @return string|null
  439. */
  440. public function getQuoteCurrencyCode()
  441. {
  442. return $this->getData(self::KEY_QUOTE_CURRENCY_CODE);
  443. }
  444. /**
  445. * Get quote currency code
  446. *
  447. * @param string $quoteCurrencyCode
  448. * @return $this
  449. */
  450. public function setQuoteCurrencyCode($quoteCurrencyCode)
  451. {
  452. return $this->setData(self::KEY_QUOTE_CURRENCY_CODE, $quoteCurrencyCode);
  453. }
  454. /**
  455. * {@inheritdoc}
  456. */
  457. public function getCouponCode()
  458. {
  459. return $this->getData(self::KEY_COUPON_CODE);
  460. }
  461. /**
  462. * {@inheritdoc}
  463. */
  464. public function setCouponCode($couponCode)
  465. {
  466. return $this->setData(self::KEY_COUPON_CODE, $couponCode);
  467. }
  468. /**
  469. * Get items qty
  470. *
  471. * @return int||null
  472. */
  473. public function getItemsQty()
  474. {
  475. return $this->getData(self::KEY_ITEMS_QTY);
  476. }
  477. /**
  478. * Set items qty
  479. *
  480. * @param int $itemsQty
  481. * @return $this
  482. */
  483. public function setItemsQty($itemsQty = null)
  484. {
  485. return $this->setData(self::KEY_ITEMS_QTY, $itemsQty);
  486. }
  487. /**
  488. * Get totals by items
  489. *
  490. * @return \Magento\Quote\Api\Data\TotalsItemInterface[]|null
  491. */
  492. public function getItems()
  493. {
  494. return $this->getData(self::KEY_ITEMS);
  495. }
  496. /**
  497. * Get totals by items
  498. *
  499. * @param \Magento\Quote\Api\Data\TotalsItemInterface[] $items
  500. * @return $this
  501. */
  502. public function setItems(array $items = null)
  503. {
  504. return $this->setData(self::KEY_ITEMS, $items);
  505. }
  506. /**
  507. * {@inheritdoc}
  508. */
  509. public function getTotalSegments()
  510. {
  511. return $this->getData(self::KEY_TOTAL_SEGMENTS);
  512. }
  513. /**
  514. * {@inheritdoc}
  515. */
  516. public function setTotalSegments($totals = [])
  517. {
  518. return $this->setData(self::KEY_TOTAL_SEGMENTS, $totals);
  519. }
  520. /**
  521. * {@inheritdoc}
  522. *
  523. * @return \Magento\Quote\Api\Data\TotalsExtensionInterface|null
  524. */
  525. public function getExtensionAttributes()
  526. {
  527. return $this->_getExtensionAttributes();
  528. }
  529. /**
  530. * {@inheritdoc}
  531. *
  532. * @param \Magento\Quote\Api\Data\TotalsExtensionInterface $extensionAttributes
  533. * @return $this
  534. */
  535. public function setExtensionAttributes(\Magento\Quote\Api\Data\TotalsExtensionInterface $extensionAttributes)
  536. {
  537. return $this->_setExtensionAttributes($extensionAttributes);
  538. }
  539. }