ShippingMethod.php 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  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\ShippingMethodInterface;
  8. /**
  9. * Quote shipping method data.
  10. *
  11. * @codeCoverageIgnore
  12. */
  13. class ShippingMethod extends \Magento\Framework\Api\AbstractExtensibleObject implements
  14. ShippingMethodInterface
  15. {
  16. /**
  17. * Returns the shipping carrier code.
  18. *
  19. * @return string Shipping carrier code.
  20. */
  21. public function getCarrierCode()
  22. {
  23. return $this->_get(self::KEY_CARRIER_CODE);
  24. }
  25. /**
  26. * Sets the shipping carrier code.
  27. *
  28. * @param string $carrierCode
  29. * @return $this
  30. */
  31. public function setCarrierCode($carrierCode)
  32. {
  33. return $this->setData(self::KEY_CARRIER_CODE, $carrierCode);
  34. }
  35. /**
  36. * Returns the shipping method code.
  37. *
  38. * @return string Shipping method code.
  39. */
  40. public function getMethodCode()
  41. {
  42. return $this->_get(self::KEY_METHOD_CODE);
  43. }
  44. /**
  45. * Sets the shipping method code.
  46. *
  47. * @param string $methodCode
  48. * @return $this
  49. */
  50. public function setMethodCode($methodCode)
  51. {
  52. return $this->setData(self::KEY_METHOD_CODE, $methodCode);
  53. }
  54. /**
  55. * Returns the shipping carrier title.
  56. *
  57. * @return string|null Shipping carrier title. Otherwise, null.
  58. */
  59. public function getCarrierTitle()
  60. {
  61. return $this->_get(self::KEY_CARRIER_TITLE);
  62. }
  63. /**
  64. * Sets the shipping carrier title.
  65. *
  66. * @param string $carrierTitle
  67. * @return $this
  68. */
  69. public function setCarrierTitle($carrierTitle)
  70. {
  71. return $this->setData(self::KEY_CARRIER_TITLE, $carrierTitle);
  72. }
  73. /**
  74. * Returns the shipping method title.
  75. *
  76. * @return string|null Shipping method title. Otherwise, null.
  77. */
  78. public function getMethodTitle()
  79. {
  80. return $this->_get(self::KEY_METHOD_TITLE);
  81. }
  82. /**
  83. * Sets the shipping method title.
  84. *
  85. * @param string $methodTitle
  86. * @return $this
  87. */
  88. public function setMethodTitle($methodTitle)
  89. {
  90. return $this->setData(self::KEY_METHOD_TITLE, $methodTitle);
  91. }
  92. /**
  93. * Returns the shipping amount in store currency.
  94. *
  95. * @return float Shipping amount in store currency.
  96. */
  97. public function getAmount()
  98. {
  99. return $this->_get(self::KEY_SHIPPING_AMOUNT);
  100. }
  101. /**
  102. * Sets the shipping amount in store currency.
  103. *
  104. * @param float $amount
  105. * @return $this
  106. */
  107. public function setAmount($amount)
  108. {
  109. return $this->setData(self::KEY_SHIPPING_AMOUNT, $amount);
  110. }
  111. /**
  112. * Returns the shipping amount in base currency.
  113. *
  114. * @return float Shipping amount in base currency.
  115. */
  116. public function getBaseAmount()
  117. {
  118. return $this->_get(self::KEY_BASE_SHIPPING_AMOUNT);
  119. }
  120. /**
  121. * Sets the shipping amount in base currency.
  122. *
  123. * @param float $baseAmount
  124. * @return $this
  125. */
  126. public function setBaseAmount($baseAmount)
  127. {
  128. return $this->setData(self::KEY_BASE_SHIPPING_AMOUNT, $baseAmount);
  129. }
  130. /**
  131. * Returns the value of the availability flag for the current shipping method.
  132. *
  133. * @return bool
  134. * @SuppressWarnings(PHPMD.BooleanGetMethodName)
  135. */
  136. public function getAvailable()
  137. {
  138. return $this->_get(self::KEY_AVAILABLE);
  139. }
  140. /**
  141. * Sets the value of the availability flag for the current shipping method.
  142. *
  143. * @param bool $available
  144. * @return $this
  145. */
  146. public function setAvailable($available)
  147. {
  148. return $this->setData(self::KEY_AVAILABLE, $available);
  149. }
  150. /**
  151. * Returns the error message.
  152. *
  153. * @return string|null Shipping Error message.
  154. */
  155. public function getErrorMessage()
  156. {
  157. return $this->_get(self::KEY_ERROR_MESSAGE);
  158. }
  159. /**
  160. * Set an error message.
  161. *
  162. * @param string|null $errorMessage
  163. * @return $this
  164. */
  165. public function setErrorMessage($errorMessage)
  166. {
  167. return $this->setData(self::KEY_ERROR_MESSAGE, $errorMessage);
  168. }
  169. /**
  170. * {@inheritdoc}
  171. *
  172. * @return \Magento\Quote\Api\Data\ShippingMethodExtensionInterface|null
  173. */
  174. public function getExtensionAttributes()
  175. {
  176. return $this->_getExtensionAttributes();
  177. }
  178. /**
  179. * {@inheritdoc}
  180. *
  181. * @param \Magento\Quote\Api\Data\ShippingMethodExtensionInterface $extensionAttributes
  182. * @return $this
  183. */
  184. public function setExtensionAttributes(
  185. \Magento\Quote\Api\Data\ShippingMethodExtensionInterface $extensionAttributes
  186. ) {
  187. return $this->_setExtensionAttributes($extensionAttributes);
  188. }
  189. /**
  190. * {@inheritdoc}
  191. *
  192. * @return float
  193. */
  194. public function getPriceExclTax()
  195. {
  196. return $this->_get(self::KEY_PRICE_EXCL_TAX);
  197. }
  198. /**
  199. * {@inheritdoc}
  200. *
  201. * @param float $priceExclTax
  202. * @return $this
  203. */
  204. public function setPriceExclTax($priceExclTax)
  205. {
  206. return $this->setData(self::KEY_PRICE_EXCL_TAX, $priceExclTax);
  207. }
  208. /**
  209. * {@inheritdoc}
  210. *
  211. * @return float
  212. */
  213. public function getPriceInclTax()
  214. {
  215. return $this->_get(self::KEY_PRICE_INCL_TAX);
  216. }
  217. /**
  218. * {@inheritdoc}
  219. *
  220. * @param float $priceInclTax
  221. * @return $this
  222. */
  223. public function setPriceInclTax($priceInclTax)
  224. {
  225. return $this->setData(self::KEY_PRICE_INCL_TAX, $priceInclTax);
  226. }
  227. }