Config.php 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. /**
  7. * Configuration paths storage
  8. *
  9. * @author Magento Core Team <core@magentocommerce.com>
  10. */
  11. namespace Magento\Tax\Model;
  12. use Magento\Store\Model\Store;
  13. /**
  14. * @SuppressWarnings(PHPMD.ExcessivePublicCount)
  15. */
  16. class Config
  17. {
  18. // tax notifications
  19. const XML_PATH_TAX_NOTIFICATION_IGNORE_DISCOUNT = 'tax/notification/ignore_discount';
  20. const XML_PATH_TAX_NOTIFICATION_IGNORE_PRICE_DISPLAY = 'tax/notification/ignore_price_display';
  21. const XML_PATH_TAX_NOTIFICATION_IGNORE_APPLY_DISCOUNT = 'tax/notification/ignore_apply_discount';
  22. const XML_PATH_TAX_NOTIFICATION_INFO_URL = 'tax/notification/info_url';
  23. // tax classes
  24. const CONFIG_XML_PATH_SHIPPING_TAX_CLASS = 'tax/classes/shipping_tax_class';
  25. // tax calculation
  26. const CONFIG_XML_PATH_PRICE_INCLUDES_TAX = 'tax/calculation/price_includes_tax';
  27. const CONFIG_XML_PATH_SHIPPING_INCLUDES_TAX = 'tax/calculation/shipping_includes_tax';
  28. const CONFIG_XML_PATH_BASED_ON = 'tax/calculation/based_on';
  29. const CONFIG_XML_PATH_APPLY_ON = 'tax/calculation/apply_tax_on';
  30. const CONFIG_XML_PATH_APPLY_AFTER_DISCOUNT = 'tax/calculation/apply_after_discount';
  31. const CONFIG_XML_PATH_DISCOUNT_TAX = 'tax/calculation/discount_tax';
  32. const XML_PATH_ALGORITHM = 'tax/calculation/algorithm';
  33. const CONFIG_XML_PATH_CROSS_BORDER_TRADE_ENABLED = 'tax/calculation/cross_border_trade_enabled';
  34. // tax defaults
  35. const CONFIG_XML_PATH_DEFAULT_COUNTRY = 'tax/defaults/country';
  36. const CONFIG_XML_PATH_DEFAULT_REGION = 'tax/defaults/region';
  37. const CONFIG_XML_PATH_DEFAULT_POSTCODE = 'tax/defaults/postcode';
  38. /**
  39. * Prices display settings
  40. */
  41. const CONFIG_XML_PATH_PRICE_DISPLAY_TYPE = 'tax/display/type';
  42. const CONFIG_XML_PATH_DISPLAY_SHIPPING = 'tax/display/shipping';
  43. /**
  44. * Shopping cart display settings
  45. */
  46. const XML_PATH_DISPLAY_CART_PRICE = 'tax/cart_display/price';
  47. const XML_PATH_DISPLAY_CART_SUBTOTAL = 'tax/cart_display/subtotal';
  48. const XML_PATH_DISPLAY_CART_SHIPPING = 'tax/cart_display/shipping';
  49. /** @deprecated */
  50. const XML_PATH_DISPLAY_CART_DISCOUNT = 'tax/cart_display/discount';
  51. const XML_PATH_DISPLAY_CART_GRANDTOTAL = 'tax/cart_display/grandtotal';
  52. const XML_PATH_DISPLAY_CART_FULL_SUMMARY = 'tax/cart_display/full_summary';
  53. const XML_PATH_DISPLAY_CART_ZERO_TAX = 'tax/cart_display/zero_tax';
  54. /**
  55. * Shopping cart display settings
  56. */
  57. const XML_PATH_DISPLAY_SALES_PRICE = 'tax/sales_display/price';
  58. const XML_PATH_DISPLAY_SALES_SUBTOTAL = 'tax/sales_display/subtotal';
  59. const XML_PATH_DISPLAY_SALES_SHIPPING = 'tax/sales_display/shipping';
  60. /** @deprecated */
  61. const XML_PATH_DISPLAY_SALES_DISCOUNT = 'tax/sales_display/discount';
  62. const XML_PATH_DISPLAY_SALES_GRANDTOTAL = 'tax/sales_display/grandtotal';
  63. const XML_PATH_DISPLAY_SALES_FULL_SUMMARY = 'tax/sales_display/full_summary';
  64. const XML_PATH_DISPLAY_SALES_ZERO_TAX = 'tax/sales_display/zero_tax';
  65. const CALCULATION_STRING_SEPARATOR = '|';
  66. const DISPLAY_TYPE_EXCLUDING_TAX = 1;
  67. const DISPLAY_TYPE_INCLUDING_TAX = 2;
  68. const DISPLAY_TYPE_BOTH = 3;
  69. /**
  70. * Price conversion constant for positive
  71. */
  72. const PRICE_CONVERSION_PLUS = 1;
  73. /**
  74. * Price conversion constant for negative
  75. */
  76. const PRICE_CONVERSION_MINUS = 2;
  77. /**
  78. * @var bool|null
  79. */
  80. protected $_priceIncludesTax = null;
  81. /**
  82. * Flag which notify what we need use shipping prices exclude tax for calculations
  83. *
  84. * @var bool
  85. */
  86. protected $_needUseShippingExcludeTax = false;
  87. /**
  88. * @var $_shippingPriceIncludeTax bool
  89. */
  90. protected $_shippingPriceIncludeTax = null;
  91. /**
  92. * Core store config
  93. *
  94. * @var \Magento\Framework\App\Config\ScopeConfigInterface
  95. */
  96. protected $_scopeConfig;
  97. /**
  98. * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
  99. */
  100. public function __construct(\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig)
  101. {
  102. $this->_scopeConfig = $scopeConfig;
  103. }
  104. /**
  105. * Check if prices of product in catalog include tax
  106. *
  107. * @param null|string|bool|int|Store $store
  108. * @return bool
  109. */
  110. public function priceIncludesTax($store = null)
  111. {
  112. if (null !== $this->_priceIncludesTax) {
  113. return $this->_priceIncludesTax;
  114. }
  115. return (bool)$this->_scopeConfig->getValue(
  116. self::CONFIG_XML_PATH_PRICE_INCLUDES_TAX,
  117. \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
  118. $store
  119. );
  120. }
  121. /**
  122. * Override "price includes tax" variable regardless of system configuration of any store
  123. *
  124. * @param bool|null $value
  125. * @return $this
  126. */
  127. public function setPriceIncludesTax($value)
  128. {
  129. if (null === $value) {
  130. $this->_priceIncludesTax = null;
  131. } else {
  132. $this->_priceIncludesTax = (bool)$value;
  133. }
  134. return $this;
  135. }
  136. /**
  137. * Check what taxes should be applied after discount
  138. *
  139. * @param null|string|bool|int|Store $store
  140. * @return bool
  141. */
  142. public function applyTaxAfterDiscount($store = null)
  143. {
  144. return (bool)$this->_scopeConfig->getValue(
  145. self::CONFIG_XML_PATH_APPLY_AFTER_DISCOUNT,
  146. \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
  147. $store
  148. );
  149. }
  150. /**
  151. * Get product price display type
  152. * 1 - Excluding tax
  153. * 2 - Including tax
  154. * 3 - Both
  155. *
  156. * @param null|string|bool|int|Store $store
  157. * @return int
  158. */
  159. public function getPriceDisplayType($store = null)
  160. {
  161. return (int)$this->_scopeConfig->getValue(
  162. self::CONFIG_XML_PATH_PRICE_DISPLAY_TYPE,
  163. \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
  164. $store
  165. );
  166. }
  167. /**
  168. * Get configuration setting "Apply Discount On Prices Including Tax" value
  169. *
  170. * @param null|string|bool|int|Store $store
  171. * @return bool
  172. */
  173. public function discountTax($store = null)
  174. {
  175. return (int)$this->_scopeConfig->getValue(
  176. self::CONFIG_XML_PATH_DISCOUNT_TAX,
  177. \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
  178. $store
  179. ) == 1;
  180. }
  181. /**
  182. * Get taxes/discounts calculation sequence.
  183. * This sequence depends on "Apply Customer Tax" and "Apply Discount On Prices" configuration options.
  184. *
  185. * @param null|int|string|Store $store
  186. * @return string
  187. */
  188. public function getCalculationSequence($store = null)
  189. {
  190. if ($this->applyTaxAfterDiscount($store)) {
  191. if ($this->discountTax($store)) {
  192. $seq = \Magento\Tax\Model\Calculation::CALC_TAX_AFTER_DISCOUNT_ON_INCL;
  193. } else {
  194. $seq = \Magento\Tax\Model\Calculation::CALC_TAX_AFTER_DISCOUNT_ON_EXCL;
  195. }
  196. } else {
  197. if ($this->discountTax($store)) {
  198. $seq = \Magento\Tax\Model\Calculation::CALC_TAX_BEFORE_DISCOUNT_ON_INCL;
  199. } else {
  200. $seq = \Magento\Tax\Model\Calculation::CALC_TAX_BEFORE_DISCOUNT_ON_EXCL;
  201. }
  202. }
  203. return $seq;
  204. }
  205. /**
  206. * Specify flag what we need use shipping price exclude tax
  207. *
  208. * @param bool $flag
  209. * @return \Magento\Tax\Model\Config
  210. */
  211. public function setNeedUseShippingExcludeTax($flag)
  212. {
  213. $this->_needUseShippingExcludeTax = $flag;
  214. return $this;
  215. }
  216. /**
  217. * Get flag what we need use shipping price exclude tax
  218. *
  219. * @return bool $flag
  220. * @SuppressWarnings(PHPMD.BooleanGetMethodName)
  221. */
  222. public function getNeedUseShippingExcludeTax()
  223. {
  224. return $this->_needUseShippingExcludeTax;
  225. }
  226. /**
  227. * Get defined tax calculation algorithm
  228. *
  229. * @param null|string|bool|int|Store $store
  230. * @return string
  231. */
  232. public function getAlgorithm($store = null)
  233. {
  234. return $this->_scopeConfig->getValue(
  235. self::XML_PATH_ALGORITHM,
  236. \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
  237. $store
  238. );
  239. }
  240. /**
  241. * Get tax class id specified for shipping tax estimation
  242. *
  243. * @param null|string|bool|int|Store $store
  244. * @return int
  245. */
  246. public function getShippingTaxClass($store = null)
  247. {
  248. return (int)$this->_scopeConfig->getValue(
  249. self::CONFIG_XML_PATH_SHIPPING_TAX_CLASS,
  250. \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
  251. $store
  252. );
  253. }
  254. /**
  255. * Get shipping methods prices display type
  256. *
  257. * @param null|string|bool|int|Store $store
  258. * @return int
  259. */
  260. public function getShippingPriceDisplayType($store = null)
  261. {
  262. return (int)$this->_scopeConfig->getValue(
  263. self::CONFIG_XML_PATH_DISPLAY_SHIPPING,
  264. \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
  265. $store
  266. );
  267. }
  268. /**
  269. * Check if shipping prices include tax
  270. *
  271. * @param null|string|bool|int|Store $store
  272. * @return bool
  273. */
  274. public function shippingPriceIncludesTax($store = null)
  275. {
  276. if ($this->_shippingPriceIncludeTax === null) {
  277. $this->_shippingPriceIncludeTax = (bool)$this->_scopeConfig->getValue(
  278. self::CONFIG_XML_PATH_SHIPPING_INCLUDES_TAX,
  279. \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
  280. $store
  281. );
  282. }
  283. return $this->_shippingPriceIncludeTax;
  284. }
  285. /**
  286. * Declare shipping prices type
  287. *
  288. * @param bool $flag
  289. * @return $this
  290. */
  291. public function setShippingPriceIncludeTax($flag)
  292. {
  293. $this->_shippingPriceIncludeTax = $flag;
  294. return $this;
  295. }
  296. /**
  297. * @param null|string|bool|int|Store $store
  298. * @return bool
  299. */
  300. public function displayCartPricesInclTax($store = null)
  301. {
  302. return $this->_scopeConfig->getValue(
  303. self::XML_PATH_DISPLAY_CART_PRICE,
  304. \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
  305. $store
  306. ) == self::DISPLAY_TYPE_INCLUDING_TAX;
  307. }
  308. /**
  309. * @param null|string|bool|int|Store $store
  310. * @return bool
  311. */
  312. public function displayCartPricesExclTax($store = null)
  313. {
  314. return $this->_scopeConfig->getValue(
  315. self::XML_PATH_DISPLAY_CART_PRICE,
  316. \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
  317. $store
  318. ) == self::DISPLAY_TYPE_EXCLUDING_TAX;
  319. }
  320. /**
  321. * @param null|string|bool|int|Store $store
  322. * @return bool
  323. */
  324. public function displayCartPricesBoth($store = null)
  325. {
  326. return $this->_scopeConfig->getValue(
  327. self::XML_PATH_DISPLAY_CART_PRICE,
  328. \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
  329. $store
  330. ) == self::DISPLAY_TYPE_BOTH;
  331. }
  332. /**
  333. * @param null|string|bool|int|Store $store
  334. * @return bool
  335. */
  336. public function displayCartSubtotalInclTax($store = null)
  337. {
  338. return $this->_scopeConfig->getValue(
  339. self::XML_PATH_DISPLAY_CART_SUBTOTAL,
  340. \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
  341. $store
  342. ) == self::DISPLAY_TYPE_INCLUDING_TAX;
  343. }
  344. /**
  345. * @param null|string|bool|int|Store $store
  346. * @return bool
  347. */
  348. public function displayCartSubtotalExclTax($store = null)
  349. {
  350. return $this->_scopeConfig->getValue(
  351. self::XML_PATH_DISPLAY_CART_SUBTOTAL,
  352. \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
  353. $store
  354. ) == self::DISPLAY_TYPE_EXCLUDING_TAX;
  355. }
  356. /**
  357. * @param null|string|bool|int|Store $store
  358. * @return bool
  359. */
  360. public function displayCartSubtotalBoth($store = null)
  361. {
  362. return $this->_scopeConfig->getValue(
  363. self::XML_PATH_DISPLAY_CART_SUBTOTAL,
  364. \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
  365. $store
  366. ) == self::DISPLAY_TYPE_BOTH;
  367. }
  368. /**
  369. * @param null|string|bool|int|Store $store
  370. * @return bool
  371. */
  372. public function displayCartShippingInclTax($store = null)
  373. {
  374. return $this->_scopeConfig->getValue(
  375. self::XML_PATH_DISPLAY_CART_SHIPPING,
  376. \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
  377. $store
  378. ) == self::DISPLAY_TYPE_INCLUDING_TAX;
  379. }
  380. /**
  381. * @param null|string|bool|int|Store $store
  382. * @return bool
  383. */
  384. public function displayCartShippingExclTax($store = null)
  385. {
  386. return $this->_scopeConfig->getValue(
  387. self::XML_PATH_DISPLAY_CART_SHIPPING,
  388. \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
  389. $store
  390. ) == self::DISPLAY_TYPE_EXCLUDING_TAX;
  391. }
  392. /**
  393. * @param null|string|bool|int|Store $store
  394. * @return bool
  395. */
  396. public function displayCartShippingBoth($store = null)
  397. {
  398. return $this->_scopeConfig->getValue(
  399. self::XML_PATH_DISPLAY_CART_SHIPPING,
  400. \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
  401. $store
  402. ) == self::DISPLAY_TYPE_BOTH;
  403. }
  404. /**
  405. * @param null|string|bool|int|Store $store
  406. * @return bool
  407. * @deprecated 100.1.3
  408. */
  409. public function displayCartDiscountInclTax($store = null)
  410. {
  411. return $this->_scopeConfig->getValue(
  412. self::XML_PATH_DISPLAY_CART_DISCOUNT,
  413. \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
  414. $store
  415. ) == self::DISPLAY_TYPE_INCLUDING_TAX;
  416. }
  417. /**
  418. * @param null|string|bool|int|Store $store
  419. * @return bool
  420. * @deprecated 100.1.3
  421. */
  422. public function displayCartDiscountExclTax($store = null)
  423. {
  424. return $this->_scopeConfig->getValue(
  425. self::XML_PATH_DISPLAY_CART_DISCOUNT,
  426. \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
  427. $store
  428. ) == self::DISPLAY_TYPE_EXCLUDING_TAX;
  429. }
  430. /**
  431. * @param null|string|bool|int|Store $store
  432. * @return bool
  433. * @deprecated 100.1.3
  434. */
  435. public function displayCartDiscountBoth($store = null)
  436. {
  437. return $this->_scopeConfig->getValue(
  438. self::XML_PATH_DISPLAY_CART_DISCOUNT,
  439. \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
  440. $store
  441. ) == self::DISPLAY_TYPE_BOTH;
  442. }
  443. /**
  444. * @param null|string|bool|int|Store $store
  445. * @return bool
  446. */
  447. public function displayCartTaxWithGrandTotal($store = null)
  448. {
  449. return (bool)$this->_scopeConfig->getValue(
  450. self::XML_PATH_DISPLAY_CART_GRANDTOTAL,
  451. \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
  452. $store
  453. );
  454. }
  455. /**
  456. * @param null|string|bool|int|Store $store
  457. * @return bool
  458. */
  459. public function displayCartFullSummary($store = null)
  460. {
  461. return (bool)$this->_scopeConfig->getValue(
  462. self::XML_PATH_DISPLAY_CART_FULL_SUMMARY,
  463. \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
  464. $store
  465. );
  466. }
  467. /**
  468. * @param null|string|bool|int|Store $store
  469. * @return bool
  470. */
  471. public function displayCartZeroTax($store = null)
  472. {
  473. return (bool)$this->_scopeConfig->getValue(
  474. self::XML_PATH_DISPLAY_CART_ZERO_TAX,
  475. \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
  476. $store
  477. );
  478. }
  479. /**
  480. * @param null|string|bool|int|Store $store
  481. * @return bool
  482. */
  483. public function displaySalesPricesInclTax($store = null)
  484. {
  485. return $this->_scopeConfig->getValue(
  486. self::XML_PATH_DISPLAY_SALES_PRICE,
  487. \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
  488. $store
  489. ) == self::DISPLAY_TYPE_INCLUDING_TAX;
  490. }
  491. /**
  492. * @param null|string|bool|int|Store $store
  493. * @return bool
  494. */
  495. public function displaySalesPricesExclTax($store = null)
  496. {
  497. return $this->_scopeConfig->getValue(
  498. self::XML_PATH_DISPLAY_SALES_PRICE,
  499. \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
  500. $store
  501. ) == self::DISPLAY_TYPE_EXCLUDING_TAX;
  502. }
  503. /**
  504. * @param null|string|bool|int|Store $store
  505. * @return bool
  506. */
  507. public function displaySalesPricesBoth($store = null)
  508. {
  509. return $this->_scopeConfig->getValue(
  510. self::XML_PATH_DISPLAY_SALES_PRICE,
  511. \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
  512. $store
  513. ) == self::DISPLAY_TYPE_BOTH;
  514. }
  515. /**
  516. * @param null|string|bool|int|Store $store
  517. * @return bool
  518. */
  519. public function displaySalesSubtotalInclTax($store = null)
  520. {
  521. return $this->_scopeConfig->getValue(
  522. self::XML_PATH_DISPLAY_SALES_SUBTOTAL,
  523. \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
  524. $store
  525. ) == self::DISPLAY_TYPE_INCLUDING_TAX;
  526. }
  527. /**
  528. * @param null|string|bool|int|Store $store
  529. * @return bool
  530. */
  531. public function displaySalesSubtotalExclTax($store = null)
  532. {
  533. return $this->_scopeConfig->getValue(
  534. self::XML_PATH_DISPLAY_SALES_SUBTOTAL,
  535. \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
  536. $store
  537. ) == self::DISPLAY_TYPE_EXCLUDING_TAX;
  538. }
  539. /**
  540. * @param null|string|bool|int|Store $store
  541. * @return bool
  542. */
  543. public function displaySalesSubtotalBoth($store = null)
  544. {
  545. return $this->_scopeConfig->getValue(
  546. self::XML_PATH_DISPLAY_SALES_SUBTOTAL,
  547. \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
  548. $store
  549. ) == self::DISPLAY_TYPE_BOTH;
  550. }
  551. /**
  552. * @param null|string|bool|int|Store $store
  553. * @return bool
  554. */
  555. public function displaySalesShippingInclTax($store = null)
  556. {
  557. return $this->_scopeConfig->getValue(
  558. self::XML_PATH_DISPLAY_SALES_SHIPPING,
  559. \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
  560. $store
  561. ) == self::DISPLAY_TYPE_INCLUDING_TAX;
  562. }
  563. /**
  564. * @param null|string|bool|int|Store $store
  565. * @return bool
  566. */
  567. public function displaySalesShippingExclTax($store = null)
  568. {
  569. return $this->_scopeConfig->getValue(
  570. self::XML_PATH_DISPLAY_SALES_SHIPPING,
  571. \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
  572. $store
  573. ) == self::DISPLAY_TYPE_EXCLUDING_TAX;
  574. }
  575. /**
  576. * @param null|string|bool|int|Store $store
  577. * @return bool
  578. */
  579. public function displaySalesShippingBoth($store = null)
  580. {
  581. return $this->_scopeConfig->getValue(
  582. self::XML_PATH_DISPLAY_SALES_SHIPPING,
  583. \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
  584. $store
  585. ) == self::DISPLAY_TYPE_BOTH;
  586. }
  587. /**
  588. * @param null|string|bool|int|Store $store
  589. * @return bool
  590. * @deprecated 100.1.3
  591. */
  592. public function displaySalesDiscountInclTax($store = null)
  593. {
  594. return $this->_scopeConfig->getValue(
  595. self::XML_PATH_DISPLAY_SALES_DISCOUNT,
  596. \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
  597. $store
  598. ) == self::DISPLAY_TYPE_INCLUDING_TAX;
  599. }
  600. /**
  601. * @param null|string|bool|int|Store $store
  602. * @return bool
  603. * @deprecated 100.1.3
  604. */
  605. public function displaySalesDiscountExclTax($store = null)
  606. {
  607. return $this->_scopeConfig->getValue(
  608. self::XML_PATH_DISPLAY_SALES_DISCOUNT,
  609. \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
  610. $store
  611. ) == self::DISPLAY_TYPE_EXCLUDING_TAX;
  612. }
  613. /**
  614. * @param null|string|bool|int|Store $store
  615. * @return bool
  616. * @deprecated 100.1.3
  617. */
  618. public function displaySalesDiscountBoth($store = null)
  619. {
  620. return $this->_scopeConfig->getValue(
  621. self::XML_PATH_DISPLAY_SALES_DISCOUNT,
  622. \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
  623. $store
  624. ) == self::DISPLAY_TYPE_BOTH;
  625. }
  626. /**
  627. * @param null|string|bool|int|Store $store
  628. * @return bool
  629. */
  630. public function displaySalesTaxWithGrandTotal($store = null)
  631. {
  632. return (bool)$this->_scopeConfig->getValue(
  633. self::XML_PATH_DISPLAY_SALES_GRANDTOTAL,
  634. \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
  635. $store
  636. );
  637. }
  638. /**
  639. * @param null|string|bool|int|Store $store
  640. * @return bool
  641. */
  642. public function displaySalesFullSummary($store = null)
  643. {
  644. return (bool)$this->_scopeConfig->getValue(
  645. self::XML_PATH_DISPLAY_SALES_FULL_SUMMARY,
  646. \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
  647. $store
  648. );
  649. }
  650. /**
  651. * @param null|string|bool|int|Store $store
  652. * @return bool
  653. */
  654. public function displaySalesZeroTax($store = null)
  655. {
  656. return (bool)$this->_scopeConfig->getValue(
  657. self::XML_PATH_DISPLAY_SALES_ZERO_TAX,
  658. \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
  659. $store
  660. );
  661. }
  662. /**
  663. * Return the config value for self::CONFIG_XML_PATH_CROSS_BORDER_TRADE_ENABLED
  664. *
  665. * @param null|string|bool|int|Store $store
  666. * @return bool
  667. */
  668. public function crossBorderTradeEnabled($store = null)
  669. {
  670. return (bool)$this->_scopeConfig->getValue(
  671. self::CONFIG_XML_PATH_CROSS_BORDER_TRADE_ENABLED,
  672. \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
  673. $store
  674. );
  675. }
  676. /**
  677. * Check if admin notification related to misconfiguration of "Apply Discount On Prices" should be ignored.
  678. *
  679. * Warning is displayed in case when "Catalog Prices" = "Excluding Tax"
  680. * AND "Apply Discount On Prices" = "Including Tax"
  681. * AND "Apply Customer Tax" = "After Discount"
  682. *
  683. * @param null|string|Store $store
  684. * @return bool
  685. */
  686. public function isWrongApplyDiscountSettingIgnored($store = null)
  687. {
  688. return (bool)$this->_scopeConfig->getValue(
  689. self::XML_PATH_TAX_NOTIFICATION_IGNORE_APPLY_DISCOUNT,
  690. \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
  691. $store
  692. );
  693. }
  694. /**
  695. * Check if do not show notification about wrong display settings
  696. *
  697. * @param null|string|bool|int|Store $store
  698. * @return bool
  699. */
  700. public function isWrongDisplaySettingsIgnored($store = null)
  701. {
  702. return (bool)$this->_scopeConfig->getValue(
  703. self::XML_PATH_TAX_NOTIFICATION_IGNORE_PRICE_DISPLAY,
  704. \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
  705. $store
  706. );
  707. }
  708. /**
  709. * Check if do not show notification about wrong discount settings
  710. *
  711. * @param null|string|bool|int|Store $store
  712. * @return bool
  713. */
  714. public function isWrongDiscountSettingsIgnored($store = null)
  715. {
  716. return (bool)$this->_scopeConfig->getValue(
  717. self::XML_PATH_TAX_NOTIFICATION_IGNORE_DISCOUNT,
  718. \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
  719. $store
  720. );
  721. }
  722. /**
  723. * Return the notification info url
  724. *
  725. * @param null|string|bool|int|Store $store
  726. * @return string
  727. */
  728. public function getInfoUrl($store = null)
  729. {
  730. return (string)$this->_scopeConfig->getValue(
  731. self::XML_PATH_TAX_NOTIFICATION_INFO_URL,
  732. \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
  733. $store
  734. );
  735. }
  736. /**
  737. * Check if necessary do product price conversion
  738. * If it necessary will be returned conversion type (minus or plus)
  739. *
  740. * @param null|int|string|Store $store
  741. * @return bool|int
  742. * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  743. */
  744. public function needPriceConversion($store = null)
  745. {
  746. $res = 0;
  747. $priceIncludesTax = $this->priceIncludesTax($store) || $this->getNeedUseShippingExcludeTax();
  748. if ($priceIncludesTax) {
  749. switch ($this->getPriceDisplayType($store)) {
  750. case self::DISPLAY_TYPE_EXCLUDING_TAX:
  751. case self::DISPLAY_TYPE_BOTH:
  752. return self::PRICE_CONVERSION_MINUS;
  753. case self::DISPLAY_TYPE_INCLUDING_TAX:
  754. $res = false;
  755. break;
  756. default:
  757. break;
  758. }
  759. } else {
  760. switch ($this->getPriceDisplayType($store)) {
  761. case self::DISPLAY_TYPE_INCLUDING_TAX:
  762. case self::DISPLAY_TYPE_BOTH:
  763. return self::PRICE_CONVERSION_PLUS;
  764. case self::DISPLAY_TYPE_EXCLUDING_TAX:
  765. $res = false;
  766. break;
  767. default:
  768. break;
  769. }
  770. }
  771. if ($res === false) {
  772. $res = $this->displayCartPricesBoth();
  773. }
  774. return $res;
  775. }
  776. }