ItemDetails.php 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Tax\Model\Sales\Quote;
  7. use Magento\Framework\Model\AbstractExtensibleModel;
  8. use Magento\Tax\Api\Data\QuoteDetailsItemInterface;
  9. /**
  10. * @codeCoverageIgnore
  11. */
  12. class ItemDetails extends AbstractExtensibleModel implements QuoteDetailsItemInterface
  13. {
  14. /**#@+
  15. * Constants defined for keys of array, makes typos less likely
  16. */
  17. const KEY_CODE = 'code';
  18. const KEY_TYPE = 'type';
  19. const KEY_TAX_CLASS_KEY = 'tax_class_key';
  20. const KEY_UNIT_PRICE = 'unit_price';
  21. const KEY_QUANTITY = 'quantity';
  22. const KEY_IS_TAX_INCLUDED = 'is_tax_included';
  23. const KEY_SHORT_DESCRIPTION = 'short_description';
  24. const KEY_DISCOUNT_AMOUNT = 'discount_amount';
  25. const KEY_PARENT_CODE = 'parent_code';
  26. const KEY_ASSOCIATED_ITEM_CODE = 'associated_item_code';
  27. const KEY_TAX_CLASS_ID = 'tax_class_id';
  28. /**#@-*/
  29. /**
  30. * {@inheritdoc}
  31. */
  32. public function getCode()
  33. {
  34. return $this->getData(self::KEY_CODE);
  35. }
  36. /**
  37. * {@inheritdoc}
  38. */
  39. public function getType()
  40. {
  41. return $this->getData(self::KEY_TYPE);
  42. }
  43. /**
  44. * {@inheritdoc}
  45. */
  46. public function getTaxClassKey()
  47. {
  48. return $this->getData(self::KEY_TAX_CLASS_KEY);
  49. }
  50. /**
  51. * {@inheritdoc}
  52. */
  53. public function getUnitPrice()
  54. {
  55. return $this->getData(self::KEY_UNIT_PRICE);
  56. }
  57. /**
  58. * {@inheritdoc}
  59. */
  60. public function getQuantity()
  61. {
  62. return $this->getData(self::KEY_QUANTITY);
  63. }
  64. /**
  65. * {@inheritdoc}
  66. */
  67. public function getIsTaxIncluded()
  68. {
  69. return $this->getData(self::KEY_IS_TAX_INCLUDED);
  70. }
  71. /**
  72. * {@inheritdoc}
  73. */
  74. public function getShortDescription()
  75. {
  76. return $this->getData(self::KEY_SHORT_DESCRIPTION);
  77. }
  78. /**
  79. * {@inheritdoc}
  80. */
  81. public function getDiscountAmount()
  82. {
  83. return $this->getData(self::KEY_DISCOUNT_AMOUNT);
  84. }
  85. /**
  86. * {@inheritdoc}
  87. */
  88. public function getParentCode()
  89. {
  90. return $this->getData(self::KEY_PARENT_CODE);
  91. }
  92. /**
  93. * {@inheritdoc}
  94. */
  95. public function getAssociatedItemCode()
  96. {
  97. return $this->getData(self::KEY_ASSOCIATED_ITEM_CODE);
  98. }
  99. /**
  100. * {@inheritdoc}
  101. */
  102. public function getTaxClassId()
  103. {
  104. return $this->getData(self::KEY_TAX_CLASS_ID);
  105. }
  106. /**
  107. * Set code (sku or shipping code)
  108. *
  109. * @param string $code
  110. * @return $this
  111. */
  112. public function setCode($code)
  113. {
  114. return $this->setData(self::KEY_CODE, $code);
  115. }
  116. /**
  117. * Set type (e.g., shipping, product, wee, gift wrapping, etc.)
  118. *
  119. * @param string $type
  120. * @return $this
  121. */
  122. public function setType($type)
  123. {
  124. return $this->setData(self::KEY_TYPE, $type);
  125. }
  126. /**
  127. * Set tax class key
  128. *
  129. * @param \Magento\Tax\Api\Data\TaxClassKeyInterface $taxClassKey
  130. * @return $this
  131. */
  132. public function setTaxClassKey(\Magento\Tax\Api\Data\TaxClassKeyInterface $taxClassKey = null)
  133. {
  134. return $this->setData(self::KEY_TAX_CLASS_KEY, $taxClassKey);
  135. }
  136. /**
  137. * Set unit price
  138. *
  139. * @param float $unitPrice
  140. * @return $this
  141. */
  142. public function setUnitPrice($unitPrice)
  143. {
  144. return $this->setData(self::KEY_UNIT_PRICE, $unitPrice);
  145. }
  146. /**
  147. * Set quantity
  148. *
  149. * @param float $quantity
  150. * @return $this
  151. */
  152. public function setQuantity($quantity)
  153. {
  154. return $this->setData(self::KEY_QUANTITY, $quantity);
  155. }
  156. /**
  157. * Set whether the tax is included in the unit price and row total
  158. *
  159. * @param bool $isTaxIncluded
  160. * @return $this
  161. */
  162. public function setIsTaxIncluded($isTaxIncluded)
  163. {
  164. return $this->setData(self::KEY_IS_TAX_INCLUDED, $isTaxIncluded);
  165. }
  166. /**
  167. * Set short description
  168. *
  169. * @param string $shortDescription
  170. * @return $this
  171. */
  172. public function setShortDescription($shortDescription)
  173. {
  174. return $this->setData(self::KEY_SHORT_DESCRIPTION, $shortDescription);
  175. }
  176. /**
  177. * Set discount amount
  178. *
  179. * @param float $discountAmount
  180. * @return $this
  181. */
  182. public function setDiscountAmount($discountAmount)
  183. {
  184. return $this->setData(self::KEY_DISCOUNT_AMOUNT, $discountAmount);
  185. }
  186. /**
  187. * Set parent code
  188. *
  189. * @param string $parentCode
  190. * @return $this
  191. */
  192. public function setParentCode($parentCode)
  193. {
  194. return $this->setData(self::KEY_PARENT_CODE, $parentCode);
  195. }
  196. /**
  197. * Set associated item code
  198. *
  199. * @param int $associatedItemCode
  200. * @return $this
  201. */
  202. public function setAssociatedItemCode($associatedItemCode)
  203. {
  204. return $this->setData(self::KEY_ASSOCIATED_ITEM_CODE, $associatedItemCode);
  205. }
  206. /**
  207. * Set associated item tax class id
  208. *
  209. * @param int $taxClassId
  210. * @return $this
  211. */
  212. public function setTaxClassId($taxClassId)
  213. {
  214. return $this->setData(self::KEY_TAX_CLASS_ID, $taxClassId);
  215. }
  216. /**
  217. * {@inheritdoc}
  218. *
  219. * @return \Magento\Tax\Api\Data\QuoteDetailsItemExtensionInterface|null
  220. */
  221. public function getExtensionAttributes()
  222. {
  223. return $this->_getExtensionAttributes();
  224. }
  225. /**
  226. * {@inheritdoc}
  227. *
  228. * @param \Magento\Tax\Api\Data\QuoteDetailsItemExtensionInterface $extensionAttributes
  229. * @return $this
  230. */
  231. public function setExtensionAttributes(
  232. \Magento\Tax\Api\Data\QuoteDetailsItemExtensionInterface $extensionAttributes
  233. ) {
  234. return $this->_setExtensionAttributes($extensionAttributes);
  235. }
  236. }