|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Copyright © O2TI. All rights reserved. |
|
4
|
|
|
* |
|
5
|
|
|
* @author Bruno Elisei <[email protected]> |
|
6
|
|
|
* See COPYING.txt for license details. |
|
7
|
|
|
*/ |
|
8
|
|
|
|
|
9
|
|
|
namespace O2TI\ThemeFullCheckout\Helper; |
|
10
|
|
|
|
|
11
|
|
|
use Magento\Framework\App\Config\ScopeConfigInterface; |
|
12
|
|
|
use Magento\Framework\App\Helper\AbstractHelper; |
|
13
|
|
|
use Magento\Store\Model\ScopeInterface; |
|
14
|
|
|
use Magento\Store\Model\StoreManagerInterface; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* Class Config - Helper configuration. |
|
18
|
|
|
*/ |
|
19
|
|
|
class Config extends AbstractHelper |
|
20
|
|
|
{ |
|
21
|
|
|
public const CONFIG_PATH_GENERAL = 'theme_full_checkout/general/%s'; |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* @var ScopeConfigInterface |
|
25
|
|
|
*/ |
|
26
|
|
|
protected $scopeConfig; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* @var StoreManagerInterface |
|
30
|
|
|
*/ |
|
31
|
|
|
protected $storeManagerInterface; |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* @param ScopeConfigInterface $scopeConfig |
|
35
|
|
|
* @param StoreManagerInterface $storeManagerInterface |
|
36
|
|
|
*/ |
|
37
|
|
|
public function __construct( |
|
38
|
|
|
ScopeConfigInterface $scopeConfig, |
|
39
|
|
|
StoreManagerInterface $storeManagerInterface |
|
40
|
|
|
) { |
|
41
|
|
|
$this->scopeConfig = $scopeConfig; |
|
42
|
|
|
$this->storeManagerInterface = $storeManagerInterface; |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* Get Configs Module. |
|
47
|
|
|
* |
|
48
|
|
|
* @param string $field |
|
49
|
|
|
* |
|
50
|
|
|
* @return string |
|
51
|
|
|
*/ |
|
52
|
|
|
public function getConfigModule(string $field): ?string |
|
53
|
|
|
{ |
|
54
|
|
|
$storeId = $this->storeManagerInterface->getStore()->getId(); |
|
55
|
|
|
$configPath = sprintf(self::CONFIG_PATH_GENERAL, $field); |
|
56
|
|
|
|
|
57
|
|
|
return $this->scopeConfig->getValue($configPath, ScopeInterface::SCOPE_STORE, $storeId); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* If module is Enabled. |
|
62
|
|
|
* |
|
63
|
|
|
* @return bool |
|
64
|
|
|
*/ |
|
65
|
|
|
public function isEnabled(): ?bool |
|
66
|
|
|
{ |
|
67
|
|
|
return $this->getConfigModule('enabled'); |
|
|
|
|
|
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
/** |
|
71
|
|
|
* If module is Move Address Billing. |
|
72
|
|
|
* |
|
73
|
|
|
* @return bool |
|
74
|
|
|
*/ |
|
75
|
|
|
public function isMoveAddressBilling(): ?bool |
|
76
|
|
|
{ |
|
77
|
|
|
return $this->getConfigModule('move_address_billing'); |
|
|
|
|
|
|
78
|
|
|
} |
|
79
|
|
|
} |
|
80
|
|
|
|