PluginProbe
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler / 1.3.27
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler v1.3.27
1.6.5 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 All 48 releases
fluent-cart / app / Services / ShortCodeParser / Parsers / SettingsParser.php

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

102 lines 2.6 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 ];
31
32 public function parse($accessor = null, $code = null): ?string
33 {
34 return $this->get($accessor, $code);
35 }
36
37 public function getStoreLogoLink(): ?string
38 {
39 return $this->storeSettings->get('store_logo.url');
40 }
41
42 public function getStoreLogo(): ?string
43 {
44 $storeLogo = $this->storeSettings->get('store_logo.url');
45 if(empty($storeLogo)){
46 return '';
47 }
48 $storeName = $this->getStoreName();
49 return "<img style='max-height: 50px' src='{$storeLogo}' alt='{$storeName}'>";
50 }
51
52 public function getStoreName(): ?string
53 {
54 return $this->storeSettings->get('store_name');
55 }
56
57 public function getStoreBrandHtml(): ?string
58 {
59 $storeLogoLink = $this->getStoreLogoLink();
60 $storeName = $this->getStoreName();
61
62 if (!$storeLogoLink) {
63 return $storeName;
64 }
65
66 return $this->getStoreLogo();
67 }
68
69 public function getStoreAddress()
70 {
71 return $this->storeSettings->get('store_address1');
72 }
73
74 public function getStoreAddressLine2()
75 {
76 return $this->storeSettings->get('store_address2');
77 }
78
79 public function getStoreCountry()
80 {
81 $country = $this->storeSettings->get('store_country');
82 return AddressHelper::getCountryNameByCode($country);
83 }
84
85 public function getStoreState()
86 {
87 $state = $this->storeSettings->get('store_state');
88 $country = $this->storeSettings->get('store_country');
89 return AddressHelper::getStateNameByCode($state,$country);
90 }
91
92 public function getStoreCity()
93 {
94 return $this->storeSettings->get('store_city');
95 }
96
97 public function getStorePostcode()
98 {
99 return $this->storeSettings->get('store_postcode');
100 }
101 }
102