Grandtotal.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Tax\Block\Checkout;
  7. /**
  8. * Subtotal Total Row Renderer
  9. */
  10. class Grandtotal extends \Magento\Checkout\Block\Total\DefaultTotal
  11. {
  12. /**
  13. * Path to template file
  14. *
  15. * @var string
  16. */
  17. protected $_template = 'Magento_Tax::checkout/grandtotal.phtml';
  18. /**
  19. * @var \Magento\Tax\Model\Config
  20. */
  21. protected $_taxConfig;
  22. /**
  23. * @param \Magento\Framework\View\Element\Template\Context $context
  24. * @param \Magento\Customer\Model\Session $customerSession
  25. * @param \Magento\Checkout\Model\Session $checkoutSession
  26. * @param \Magento\Sales\Model\Config $salesConfig
  27. * @param \Magento\Tax\Model\Config $taxConfig
  28. * @param array $layoutProcessors
  29. * @param array $data
  30. */
  31. public function __construct(
  32. \Magento\Framework\View\Element\Template\Context $context,
  33. \Magento\Customer\Model\Session $customerSession,
  34. \Magento\Checkout\Model\Session $checkoutSession,
  35. \Magento\Sales\Model\Config $salesConfig,
  36. \Magento\Tax\Model\Config $taxConfig,
  37. array $layoutProcessors = [],
  38. array $data = []
  39. ) {
  40. $this->_taxConfig = $taxConfig;
  41. parent::__construct($context, $customerSession, $checkoutSession, $salesConfig, $layoutProcessors, $data);
  42. $this->_isScopePrivate = true;
  43. }
  44. /**
  45. * Check if we have include tax amount between grandtotal incl/excl tax
  46. *
  47. * @return bool
  48. */
  49. public function includeTax()
  50. {
  51. if ($this->getTotal()->getValue()) {
  52. return $this->_taxConfig->displayCartTaxWithGrandTotal($this->getStore());
  53. }
  54. return false;
  55. }
  56. /**
  57. * Get grandtotal exclude tax
  58. *
  59. * @return float
  60. */
  61. public function getTotalExclTax()
  62. {
  63. $excl = $this->getTotal()->getValue() - $this->_totals['tax']->getValue();
  64. $excl = max($excl, 0);
  65. return $excl;
  66. }
  67. }