PluginProbe ʕ •ᴥ•ʔ
ShopEngine Elementor WooCommerce Builder Addon – All in One WooCommerce Solution / 1.2.0
ShopEngine Elementor WooCommerce Builder Addon – All in One WooCommerce Solution v1.2.0
4.9.2 4.9.1 4.9.0 2.0.0 2.1.0 2.2.0 2.2.1 2.2.2 2.3.0 2.4.0 2.5.0 2.5.1 3.0.0 3.1.0 3.1.1 4.0.0 4.0.1 4.1.0 4.1.1 4.2.0 4.2.1 4.3.0 4.3.1 4.4.0 4.5.0 4.5.1 4.6.0 4.6.1 4.6.2 4.6.3 4.6.4 4.6.5 4.6.6 4.6.7 4.6.8 4.6.9 4.7.0 4.7.1 4.7.2 4.7.3 4.7.4 4.7.5 4.7.6 4.7.7 4.7.8 4.7.9 4.8.0 4.8.1 4.8.2 4.8.3 4.8.4 4.8.5 4.8.6 4.8.7 4.8.8 4.8.9 trunk 0.1.2-beta 0.1.3-beta 0.1.4-beta 1.0.0 1.1.0 1.1.1 1.1.2 1.1.3 1.2.0 1.2.1 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.4.0 1.4.1 1.5.0 1.5.1 1.6.0 1.6.1 1.7.0 1.8.0 1.8.1 1.9.0
shopengine / core / builders / base.php
shopengine / core / builders Last commit date
action.php 4 years ago api.php 5 years ago base.php 4 years ago hooks.php 4 years ago templates.php 4 years ago
base.php
212 lines
1 <?php
2
3 namespace ShopEngine\Core\Builders;
4
5 use ShopEngine\Base\Common;
6 use ShopEngine\Core\Export_Import\Export;
7 use ShopEngine\Core\Export_Import\Import;
8 use ShopEngine\Core\PageTemplates\Page_Templates;
9 use ShopEngine\Core\Template_Cpt;
10 use ShopEngine\Traits\Singleton;
11 use ShopEngine\Utils\Elementor_Data_Map;
12
13 defined('ABSPATH') || exit;
14
15 class Base extends Common
16 {
17
18 use Singleton;
19
20 // $api variable call for Cpt Class Instance
21 public $form;
22
23 // $api variable call for Api Class Instance
24 public $api;
25
26 public function get_dir() {
27
28 return dirname(__FILE__);
29 }
30
31
32 /**
33 *
34 * @since 1.0.0
35 *
36 */
37 public function init() {
38
39 $this->api = new Api();
40
41 #Registering custom post type
42 Template_Cpt::instance()->init();
43
44 #All hooks
45 Hooks::instance()->init();
46
47 add_filter( "theme_shopengine-template_templates", [ $this, 'add_page_templates' ], 999, 4 );
48
49 add_action('wp', [Page_Templates::instance(), 'init'], 999);
50
51 add_filter('woocommerce_checkout_fields', [$this, 'disabling_fields'], 999);
52
53 (new Export())->init();
54 (new Import())->init();
55 }
56
57 public function add_page_templates( $page_templates, $wp_theme, $post ) {
58
59 unset($page_templates['elementor_theme']);
60 return $page_templates;
61 }
62
63 public function disabling_fields($fields) {
64
65 // checkout page
66 // - is any checkout template active ?
67 // - - then it is overriding the template
68 // - - - then add the filter
69
70 if(is_checkout()) {
71
72 $template_id = $this->get_template_id('checkout');
73
74 if(!empty($template_id)) {
75
76 $current_page_id = get_the_ID();
77 $mapper = new Elementor_Data_Map();
78
79 $dt = $mapper->get_elementor_data($template_id);
80 $els = $mapper->get_widget_data('shopengine-checkout-form-billing', $dt);
81
82 if(!empty($els[0]->settings)) {
83
84 $obj = $els[0]->settings;
85 unset($els);
86
87 if(!empty($obj->shopengine_hide_billing_first_name_field)) {
88
89 unset($fields['billing']['billing_first_name']);
90 }
91
92 if(!empty($obj->shopengine_hide_billing_last_name_field)) {
93
94 unset($fields['billing']['billing_last_name']);
95 }
96
97 if(!empty($obj->shopengine_hide_billing_company_field)) {
98
99 unset($fields['billing']['billing_company']);
100 }
101
102 if(!empty($obj->shopengine_hide_billing_country_field)) {
103
104 unset($fields['billing']['billing_country']);
105 }
106
107 if(!empty($obj->shopengine_hide_billing_address_1_field)) {
108
109 unset($fields['billing']['billing_address_1']);
110 }
111
112 if(!empty($obj->shopengine_hide_billing_address_2_field)) {
113
114 unset($fields['billing']['billing_address_2']);
115 }
116
117 if(!empty($obj->shopengine_hide_billing_city_field)) {
118
119 unset($fields['billing']['billing_city']);
120 }
121
122 if(!empty($obj->shopengine_hide_billing_state_field)) {
123
124 unset($fields['billing']['billing_state']);
125 }
126
127 if(!empty($obj->shopengine_hide_billing_postcode_field)) {
128
129 unset($fields['billing']['billing_postcode']);
130 }
131
132 if(!empty($obj->shopengine_hide_billing_phone_field)) {
133
134 unset($fields['billing']['billing_phone']);
135 }
136
137 if(!empty($obj->shopengine_hide_billing_email_field)) {
138
139 unset($fields['billing']['billing_email']);
140 }
141 }
142
143 $els = $mapper->get_widget_data('shopengine-checkout-form-shipping', $dt);
144
145 if(!empty($els[0]->settings)) {
146
147 $obj = $els[0]->settings;
148 unset($els);
149
150 if(!empty($obj->shopengine_hide_billing_first_name_field)) {
151
152 unset($fields['shipping']['shipping_first_name']);
153 }
154
155 if(!empty($obj->shopengine_hide_shipping_last_name_field)) {
156
157 unset($fields['shipping']['shipping_last_name']);
158 }
159
160 if(!empty($obj->shopengine_hide_shipping_company_field)) {
161
162 unset($fields['shipping']['shipping_company']);
163 }
164
165 if(!empty($obj->shopengine_hide_shipping_country_field)) {
166
167 unset($fields['shipping']['shipping_country']);
168 }
169
170 if(!empty($obj->shopengine_hide_shipping_address_1_field)) {
171
172 unset($fields['shipping']['shipping_address_1']);
173 }
174
175 if(!empty($obj->shopengine_hide_shipping_address_2_field)) {
176
177 unset($fields['shipping']['shipping_address_2']);
178 }
179
180 if(!empty($obj->shopengine_hide_shipping_city_field)) {
181
182 unset($fields['shipping']['shipping_city']);
183 }
184
185 if(!empty($obj->shopengine_hide_shipping_state_field)) {
186
187 unset($fields['shipping']['shipping_state']);
188 }
189
190 if(!empty($obj->shopengine_hide_shipping_postcode_field)) {
191
192 unset($fields['shipping']['shipping_postcode']);
193 }
194 }
195
196 } else {
197
198 // var_dump('ohh....... no checkout template is active!');
199
200 }
201 }
202
203
204 return $fields;
205 }
206
207 public function get_template_id($type) {
208
209 return \ShopEngine\Core\Builders\Templates::get_registered_template_id($type);
210 }
211 }
212