Shipping.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Sales\Block\Adminhtml\Order\Create\Totals;
  7. use Magento\Framework\Pricing\PriceCurrencyInterface;
  8. /**
  9. * Subtotal Total Row Renderer
  10. *
  11. * @author Magento Core Team <core@magentocommerce.com>
  12. * @SuppressWarnings(PHPMD.DepthOfInheritance)
  13. */
  14. class Shipping extends \Magento\Sales\Block\Adminhtml\Order\Create\Totals\DefaultTotals
  15. {
  16. /**
  17. * Template
  18. *
  19. * @var string
  20. */
  21. protected $_template = 'Magento_Sales::order/create/totals/shipping.phtml';
  22. /**
  23. * Tax config
  24. *
  25. * @var \Magento\Tax\Model\Config
  26. */
  27. protected $_taxConfig;
  28. /**
  29. * @param \Magento\Backend\Block\Template\Context $context
  30. * @param \Magento\Backend\Model\Session\Quote $sessionQuote
  31. * @param \Magento\Sales\Model\AdminOrder\Create $orderCreate
  32. * @param \Magento\Sales\Helper\Data $salesData
  33. * @param \Magento\Sales\Model\Config $salesConfig
  34. * @param PriceCurrencyInterface $priceCurrency
  35. * @param \Magento\Tax\Model\Config $taxConfig
  36. * @param array $data
  37. */
  38. public function __construct(
  39. \Magento\Backend\Block\Template\Context $context,
  40. \Magento\Backend\Model\Session\Quote $sessionQuote,
  41. \Magento\Sales\Model\AdminOrder\Create $orderCreate,
  42. PriceCurrencyInterface $priceCurrency,
  43. \Magento\Sales\Helper\Data $salesData,
  44. \Magento\Sales\Model\Config $salesConfig,
  45. \Magento\Tax\Model\Config $taxConfig,
  46. array $data = []
  47. ) {
  48. $this->_taxConfig = $taxConfig;
  49. parent::__construct($context, $sessionQuote, $orderCreate, $priceCurrency, $salesData, $salesConfig, $data);
  50. }
  51. /**
  52. * Check if we need display shipping include and exclude tax
  53. *
  54. * @return bool
  55. */
  56. public function displayBoth()
  57. {
  58. return $this->_taxConfig->displayCartShippingBoth();
  59. }
  60. /**
  61. * Check if we need display shipping include tax
  62. *
  63. * @return bool
  64. */
  65. public function displayIncludeTax()
  66. {
  67. return $this->_taxConfig->displayCartShippingInclTax();
  68. }
  69. /**
  70. * Get shipping amount include tax
  71. *
  72. * @return float
  73. */
  74. public function getShippingIncludeTax()
  75. {
  76. return $this->getTotal()->getShippingInclTax();
  77. }
  78. /**
  79. * Get shipping amount exclude tax
  80. *
  81. * @return float
  82. */
  83. public function getShippingExcludeTax()
  84. {
  85. return $this->getTotal()->getValue();
  86. }
  87. /**
  88. * Get label for shipping include tax
  89. *
  90. * @return \Magento\Framework\Phrase
  91. */
  92. public function getIncludeTaxLabel()
  93. {
  94. return __(
  95. 'Shipping Incl. Tax (%1)',
  96. $this->escapeHtml($this->getQuote()->getShippingAddress()->getShippingDescription())
  97. );
  98. }
  99. /**
  100. * Get label for shipping exclude tax
  101. *
  102. * @return \Magento\Framework\Phrase
  103. */
  104. public function getExcludeTaxLabel()
  105. {
  106. return __(
  107. 'Shipping Excl. Tax (%1)',
  108. $this->escapeHtml($this->getQuote()->getShippingAddress()->getShippingDescription())
  109. );
  110. }
  111. }