PluginProbe ʕ •ᴥ•ʔ
ShopEngine Elementor WooCommerce Builder Addon – All in One WooCommerce Solution / 4.8.2
ShopEngine Elementor WooCommerce Builder Addon – All in One WooCommerce Solution v4.8.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 1 year ago api.php 4 years ago base.php 1 year ago hooks.php 3 years ago templates.php 3 years ago
base.php
242 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 use Singleton;
18
19 // $api variable call for Cpt Class Instance
20 public $form;
21
22 // $api variable call for Api Class Instance
23 public $api;
24
25 public function get_dir() {
26
27 return dirname(__FILE__);
28 }
29
30
31 /**
32 *
33 * @since 1.0.0
34 *
35 */
36 public function init() {
37
38 $this->api = new Api();
39
40 #Registering custom post type
41 Template_Cpt::instance()->init();
42
43 $cpt_type = Template_Cpt::TYPE;
44
45 #All hooks
46 Hooks::instance()->init();
47
48 add_filter("theme_{$cpt_type}_templates", [$this, 'add_page_templates'], 999, 4);
49 add_filter("elementor/document/urls/wp_preview", [$this, 'change_preview_editor_url'], 999, 2);
50
51
52 add_action('wp', [Page_Templates::instance(), 'init'], 999);
53
54 add_filter('woocommerce_checkout_fields', [$this, 'disabling_fields'], 999);
55
56 (new Export())->init();
57 (new Import())->init();
58 }
59
60
61 public function change_preview_editor_url($url, $document) {
62 $post_id = $document->get_main_id();
63 $template = \ShopEngine\Core\Builders\Templates::get_registered_template_data($post_id);
64
65 if(empty($template) || !isset($template['url']) || get_post_type($post_id) !== Template_Cpt::TYPE) {
66 return $url;
67 }
68
69 $param = [
70 'shopengine_template_id' => $post_id,
71 'preview_nonce' => wp_create_nonce('template_preview_' . $post_id),
72 'change_template' => '1',
73 ];
74
75 $url = \ShopEngine\Utils\Helper::add_to_url($template['url'], $param);
76
77
78 return $url;
79 }
80
81
82
83 public function add_page_templates($page_templates, $wp_theme, $post) {
84
85 unset($page_templates['elementor_theme']);
86
87 $page_templates['shopengine_canvas_tpl'] = esc_html__('Shopengine Canvas', 'shopengine');
88 $page_templates['shopengine_full_width_tpl'] = esc_html__('Shopengine Full width', 'shopengine');
89
90 return $page_templates;
91 }
92
93 public function disabling_fields($fields) {
94
95 // checkout page
96 // - is any checkout template active ?
97 // - - then it is overriding the template
98 // - - - then add the filter
99
100 if(is_checkout()) {
101
102 $template_id = $this->get_template_id('checkout');
103
104 if(!empty($template_id)) {
105
106 $current_page_id = get_the_ID();
107 $mapper = new Elementor_Data_Map();
108
109 $dt = $mapper->get_elementor_data($template_id);
110 $els = $mapper->get_widget_data('shopengine-checkout-form-billing', $dt);
111
112 if(!empty($els[0]->settings)) {
113
114 $obj = $els[0]->settings;
115 unset($els);
116
117 if(!empty($obj->shopengine_hide_billing_first_name_field)) {
118
119 unset($fields['billing']['billing_first_name']);
120 }
121
122 if(!empty($obj->shopengine_hide_billing_last_name_field)) {
123
124 unset($fields['billing']['billing_last_name']);
125 }
126
127 if(!empty($obj->shopengine_hide_billing_company_field)) {
128
129 unset($fields['billing']['billing_company']);
130 }
131
132 if(!empty($obj->shopengine_hide_billing_country_field)) {
133
134 unset($fields['billing']['billing_country']);
135 }
136
137 if(!empty($obj->shopengine_hide_billing_address_1_field)) {
138
139 unset($fields['billing']['billing_address_1']);
140 }
141
142 if(!empty($obj->shopengine_hide_billing_address_2_field)) {
143
144 unset($fields['billing']['billing_address_2']);
145 }
146
147 if(!empty($obj->shopengine_hide_billing_city_field)) {
148
149 unset($fields['billing']['billing_city']);
150 }
151
152 if(!empty($obj->shopengine_hide_billing_state_field)) {
153
154 unset($fields['billing']['billing_state']);
155 }
156
157 if(!empty($obj->shopengine_hide_billing_postcode_field)) {
158
159 unset($fields['billing']['billing_postcode']);
160 }
161
162 if(!empty($obj->shopengine_hide_billing_phone_field)) {
163
164 unset($fields['billing']['billing_phone']);
165 }
166
167 if(!empty($obj->shopengine_hide_billing_email_field)) {
168
169 unset($fields['billing']['billing_email']);
170 }
171 }
172
173 $els = $mapper->get_widget_data('shopengine-checkout-form-shipping', $dt);
174
175 if(!empty($els[0]->settings)) {
176
177 $obj = $els[0]->settings;
178 unset($els);
179
180 if(!empty($obj->shopengine_hide_billing_first_name_field)) {
181
182 unset($fields['shipping']['shipping_first_name']);
183 }
184
185 if(!empty($obj->shopengine_hide_shipping_last_name_field)) {
186
187 unset($fields['shipping']['shipping_last_name']);
188 }
189
190 if(!empty($obj->shopengine_hide_shipping_company_field)) {
191
192 unset($fields['shipping']['shipping_company']);
193 }
194
195 if(!empty($obj->shopengine_hide_shipping_country_field)) {
196
197 unset($fields['shipping']['shipping_country']);
198 }
199
200 if(!empty($obj->shopengine_hide_shipping_address_1_field)) {
201
202 unset($fields['shipping']['shipping_address_1']);
203 }
204
205 if(!empty($obj->shopengine_hide_shipping_address_2_field)) {
206
207 unset($fields['shipping']['shipping_address_2']);
208 }
209
210 if(!empty($obj->shopengine_hide_shipping_city_field)) {
211
212 unset($fields['shipping']['shipping_city']);
213 }
214
215 if(!empty($obj->shopengine_hide_shipping_state_field)) {
216
217 unset($fields['shipping']['shipping_state']);
218 }
219
220 if(!empty($obj->shopengine_hide_shipping_postcode_field)) {
221
222 unset($fields['shipping']['shipping_postcode']);
223 }
224 }
225
226 } else {
227
228 // var_dump('ohh....... no checkout template is active!');
229
230 }
231 }
232
233
234 return $fields;
235 }
236
237 public function get_template_id($type) {
238
239 return \ShopEngine\Core\Builders\Templates::get_registered_template_id($type);
240 }
241 }
242