CheckoutTotalsJsLayoutDataProvider.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Tax\CustomerData;
  7. use Magento\Customer\CustomerData\JsLayoutDataProviderInterface;
  8. /**
  9. * Checkout totals js layout data provider
  10. */
  11. class CheckoutTotalsJsLayoutDataProvider implements JsLayoutDataProviderInterface
  12. {
  13. /**
  14. * @var \Magento\Tax\Model\Config
  15. */
  16. protected $taxConfig;
  17. /**
  18. * @param \Magento\Tax\Model\Config $taxConfig
  19. */
  20. public function __construct(
  21. \Magento\Tax\Model\Config $taxConfig
  22. ) {
  23. $this->taxConfig = $taxConfig;
  24. }
  25. /**
  26. * {@inheritdoc}
  27. */
  28. public function getData()
  29. {
  30. return [
  31. 'components' => [
  32. 'minicart_content' => [
  33. 'children' => [
  34. 'subtotal.container' => [
  35. 'children' => [
  36. 'subtotal' => [
  37. 'children' => [
  38. 'subtotal.totals' => [
  39. 'config' => $this->getTotalsConfig(),
  40. ],
  41. ],
  42. ],
  43. ],
  44. ],
  45. ],
  46. ],
  47. ],
  48. ];
  49. }
  50. /**
  51. * Get totals config
  52. *
  53. * @return array
  54. */
  55. protected function getTotalsConfig()
  56. {
  57. return [
  58. 'display_cart_subtotal_incl_tax' => (int)$this->taxConfig->displayCartSubtotalInclTax(),
  59. 'display_cart_subtotal_excl_tax' => (int)$this->taxConfig->displayCartSubtotalExclTax(),
  60. ];
  61. }
  62. }