PluginProbe
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler / 1.6.4
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler v1.6.4
1.6.4 1.6.3 1.6.2 1.6.1 1.6.0 1.5.4 1.5.5 1.5.3 1.5.2 1.5.1 1.5.0 1.4.2 1.4.1 1.4.0 1.3.28 1.3.27 1.3.26 1.3.25 1.3.23 1.3.22 1.3.21 1.3.20 1.3.19 trunk 1.2.0 All 47 releases
fluent-cart / app / Services / ShortCodeParser / Parsers / SettingsParser.php

SettingsParser.php in FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler 1.6.4, at app/Services/ShortCodeParser/Parsers/SettingsParser.php

126 lines 3.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FluentCart\App\Services\ShortCodeParser\Parsers;
4
5 use FluentCart\Api\StoreSettings;
6 use FluentCart\App\Helpers\AddressHelper;
7 use FluentCart\App\Services\Localization\LocalizationManager;
8
9 class SettingsParser extends BaseParser
10 {
11 private StoreSettings $storeSettings;
12
13
14 public function __construct($data)
15 {
16 $this->storeSettings = new StoreSettings();
17 parent::__construct($data);
18 }
19
20 protected array $methodMap = [
21 'store_logo' => 'getStoreLogo',
22 'store_brand' => 'getStoreBrandHtml',
23 'store_name' => 'getStoreName',
24 'store_address' => 'getStoreAddress',
25 'store_address2' => 'getStoreAddressLine2',
26 'store_country' => 'getStoreCountry',
27 'store_state' => 'getStoreState',
28 'store_city' => 'getStoreCity',
29 'store_postcode' => 'getStorePostcode',
30 'company_name' => 'getCompanyName',
31 'legal_registration_id' => 'getLegalRegistrationId',
32 'seller_vat_id' => 'getSellerVatId',
33 'seller_tax_id' => 'getSellerTaxId',
34 ];
35
36 public function parse($accessor = null, $code = null): ?string
37 {
38 return $this->get($accessor, $code);
39 }
40
41 public function getStoreLogoLink(): ?string
42 {
43 return $this->storeSettings->get('store_logo.url');
44 }
45
46 public function getStoreLogo(): ?string
47 {
48 $storeLogo = $this->storeSettings->get('store_logo.url');
49 if(empty($storeLogo)){
50 return '';
51 }
52 $storeName = $this->getStoreName();
53 return "<img style='max-height: 50px' src='{$storeLogo}' alt='{$storeName}'>";
54 }
55
56 public function getStoreName(): ?string
57 {
58 return $this->storeSettings->get('store_name');
59 }
60
61 public function getStoreBrandHtml(): ?string
62 {
63 $storeLogoLink = $this->getStoreLogoLink();
64 $storeName = $this->getStoreName();
65
66 if (!$storeLogoLink) {
67 return $storeName;
68 }
69
70 return $this->getStoreLogo();
71 }
72
73 public function getStoreAddress()
74 {
75 return $this->storeSettings->get('store_address1');
76 }
77
78 public function getStoreAddressLine2()
79 {
80 return $this->storeSettings->get('store_address2');
81 }
82
83 public function getStoreCountry()
84 {
85 $country = $this->storeSettings->get('store_country');
86 return AddressHelper::getCountryNameByCode($country);
87 }
88
89 public function getStoreState()
90 {
91 $state = $this->storeSettings->get('store_state');
92 $country = $this->storeSettings->get('store_country');
93 return AddressHelper::getStateNameByCode($state,$country);
94 }
95
96 public function getStoreCity()
97 {
98 return $this->storeSettings->get('store_city');
99 }
100
101 public function getStorePostcode()
102 {
103 return $this->storeSettings->get('store_postcode');
104 }
105
106 public function getCompanyName(): ?string
107 {
108 return $this->storeSettings->get('company_name');
109 }
110
111 public function getLegalRegistrationId(): ?string
112 {
113 return $this->storeSettings->get('legal_registration_id');
114 }
115
116 public function getSellerVatId(): ?string
117 {
118 return $this->storeSettings->get('seller_vat_id');
119 }
120
121 public function getSellerTaxId(): ?string
122 {
123 return $this->storeSettings->get('seller_tax_id');
124 }
125 }
126