Config.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Weee\Model;
  7. use Magento\Store\Model\Store;
  8. /**
  9. * WEEE config model
  10. */
  11. class Config
  12. {
  13. /**
  14. * Enabled config path
  15. */
  16. const XML_PATH_FPT_ENABLED = 'tax/weee/enable';
  17. // display settings
  18. const XML_PATH_FPT_DISPLAY_PRODUCT_VIEW = 'tax/weee/display';
  19. const XML_PATH_FPT_DISPLAY_PRODUCT_LIST = 'tax/weee/display_list';
  20. const XML_PATH_FPT_DISPLAY_SALES = 'tax/weee/display_sales';
  21. const XML_PATH_FPT_DISPLAY_EMAIL = 'tax/weee/display_email';
  22. // misc
  23. const XML_PATH_FPT_INCLUDE_IN_SUBTOTAL = 'tax/weee/include_in_subtotal';
  24. const XML_PATH_FPT_TAXABLE = 'tax/weee/apply_vat';
  25. /**
  26. * Core store config
  27. *
  28. * @var \Magento\Framework\App\Config\ScopeConfigInterface
  29. */
  30. protected $scopeConfig;
  31. /**
  32. * @param \Magento\Tax\Helper\Data $taxData
  33. * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
  34. */
  35. public function __construct(
  36. \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
  37. \Magento\Tax\Helper\Data $taxData
  38. ) {
  39. $this->taxHelper = $taxData;
  40. $this->scopeConfig = $scopeConfig;
  41. }
  42. /**
  43. * Get weee amount display type on product view page
  44. *
  45. * @param null|string|bool|int|Store $store
  46. * @return int
  47. */
  48. public function getPriceDisplayType($store = null)
  49. {
  50. return $this->scopeConfig->getValue(
  51. self::XML_PATH_FPT_DISPLAY_PRODUCT_VIEW,
  52. \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
  53. $store
  54. );
  55. }
  56. /**
  57. * Get weee amount display type on product list page
  58. *
  59. * @param null|string|bool|int|Store $store
  60. * @return int
  61. */
  62. public function getListPriceDisplayType($store = null)
  63. {
  64. return $this->scopeConfig->getValue(
  65. self::XML_PATH_FPT_DISPLAY_PRODUCT_LIST,
  66. \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
  67. $store
  68. );
  69. }
  70. /**
  71. * Get weee amount display type in sales modules
  72. *
  73. * @param null|string|bool|int|Store $store
  74. * @return int
  75. */
  76. public function getSalesPriceDisplayType($store = null)
  77. {
  78. return $this->scopeConfig->getValue(
  79. self::XML_PATH_FPT_DISPLAY_SALES,
  80. \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
  81. $store
  82. );
  83. }
  84. /**
  85. * Get weee amount display type in email templates
  86. *
  87. * @param null|string|bool|int|Store $store
  88. * @return int
  89. */
  90. public function getEmailPriceDisplayType($store = null)
  91. {
  92. return $this->scopeConfig->getValue(
  93. self::XML_PATH_FPT_DISPLAY_EMAIL,
  94. \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
  95. $store
  96. );
  97. }
  98. /**
  99. * Check if weee tax amount should be included to subtotal
  100. *
  101. * @param null|string|bool|int|Store $store
  102. * @return bool
  103. */
  104. public function includeInSubtotal($store = null)
  105. {
  106. return $this->scopeConfig->isSetFlag(
  107. self::XML_PATH_FPT_INCLUDE_IN_SUBTOTAL,
  108. \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
  109. $store
  110. );
  111. }
  112. /**
  113. * Check if weee tax amount should be taxable
  114. *
  115. * @param null|string|bool|int|Store $store
  116. * @return bool
  117. */
  118. public function isTaxable($store = null)
  119. {
  120. return $this->scopeConfig->isSetFlag(
  121. self::XML_PATH_FPT_TAXABLE,
  122. \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
  123. $store
  124. );
  125. }
  126. /**
  127. * Check if fixed taxes are used in system
  128. *
  129. * @param null|string|bool|int|Store $store
  130. * @return bool
  131. */
  132. public function isEnabled($store = null)
  133. {
  134. return $this->scopeConfig->getValue(
  135. self::XML_PATH_FPT_ENABLED,
  136. \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
  137. $store
  138. );
  139. }
  140. }