Method.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Quote\Model\Quote\Address\RateResult;
  7. /**
  8. * Fields:
  9. * - carrier: carrier code
  10. * - carrierTitle: carrier title
  11. * - method: carrier method
  12. * - methodTitle: method title
  13. * - price: cost+handling
  14. * - cost: cost
  15. *
  16. * @api
  17. * @since 100.0.2
  18. */
  19. class Method extends AbstractResult
  20. {
  21. /**
  22. * @var \Magento\Framework\Pricing\PriceCurrencyInterface
  23. */
  24. protected $priceCurrency;
  25. /**
  26. * @param \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency
  27. * @param array $data
  28. */
  29. public function __construct(
  30. \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency,
  31. array $data = []
  32. ) {
  33. $this->priceCurrency = $priceCurrency;
  34. parent::__construct($data);
  35. }
  36. /**
  37. * Round shipping carrier's method price
  38. *
  39. * @param string|float|int $price
  40. * @return $this
  41. */
  42. public function setPrice($price)
  43. {
  44. $this->setData('price', $this->priceCurrency->round($price));
  45. return $this;
  46. }
  47. }