PluginProbe
Page Builder: Pagelayer – Drag and Drop website builder / 2.2.0
Page Builder: Pagelayer – Drag and Drop website builder v2.2.0
2.2.1 2.2.0 2.1.9 2.1.8 2.1.7 2.1.6 2.1.5 2.1.4 2.1.3 trunk 0.9.0 0.9.1 0.9.2 0.9.3 0.9.4 0.9.5 0.9.6 0.9.7 0.9.8 0.9.9 1.0.0 1.0.2 1.0.3 1.0.4 1.0.5 All 129 releases
pagelayer / main / woocommerce.php

woocommerce.php in Page Builder: Pagelayer – Drag and Drop website builder 2.2.0, at main/woocommerce.php

742 lines 22.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 //////////////////////////////////////////////////////////////
4 //===========================================================
5 // PAGELAYER
6 // Inspired by the DESIRE to be the BEST OF ALL
7 // ----------------------------------------------------------
8 // Started by: Pulkit Gupta
9 // Date: 23rd Jan 2017
10 // Time: 23:00 hrs
11 // Site: http://pagelayer.com/wordpress (PAGELAYER)
12 // ----------------------------------------------------------
13 // Please Read the Terms of use at http://pagelayer.com/tos
14 // ----------------------------------------------------------
15 //===========================================================
16 // (c)Pagelayer Team
17 //===========================================================
18 //////////////////////////////////////////////////////////////
19
20 // Are we being accessed directly ?
21 if(!defined('PAGELAYER_VERSION')) {
22 exit('Hacking Attempt !');
23 }
24
25 add_action( 'wp', 'pagelayer_wc_customization' );
26 function pagelayer_wc_customization(){
27
28 $options = pagelayer_get_customize_options();
29
30 if(!empty($options['woo_disable_cross_sells'])){
31 remove_action( 'woocommerce_cart_collaterals', 'woocommerce_cross_sell_display' );
32 }
33
34 if(is_product()){
35 // Disable Breadcrumb.
36 if(!empty($options['woo_disable_breadcrumb'])){
37 remove_action( 'woocommerce_before_main_content', 'woocommerce_breadcrumb', 20, 0 );
38 }
39 }
40
41 // Checkout customization
42 if(!is_checkout()){
43 return;
44 }
45
46 // Disable order notes.
47 if(!empty( $options['woo_disable_order_note'] )){
48 add_filter( 'woocommerce_enable_order_notes_field', '__return_false' );
49 }
50
51 // Disable coupon.
52 if(!empty( $options['woo_disable_coupon_field'] )){
53 remove_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_coupon_form', 10 );
54 }
55 }
56
57 add_filter('wp_nav_menu_items', 'pagelayer_add_woo_cart', 10, 2);
58 add_filter('wp_page_menu', 'pagelayer_add_woo_cart', 10, 2);
59 function pagelayer_add_woo_cart($items, $args) {
60
61 $menu_id = isset($args->menu->term_id) ? $args->menu->term_id : '';
62 $locations = get_nav_menu_locations();
63
64 //pagelayer_print($locations);
65 if(empty($locations) || !isset($locations['primary']) || $locations['primary'] != $menu_id) {
66 return $items;
67 }
68
69 $options = pagelayer_get_customize_options();
70
71 if(!empty($options['woo_enable_menu_cart'])) {
72 $items .= '<li class="page-item pagelayer-menu-cart cart-customlocation menu-item menu-item-type-post_type menu-item-object-page"><a href=""><span class="dashicons dashicons-cart"></span><sup></sup></a></li>';
73 }
74
75 return $items;
76 }
77
78 add_action( 'customize_controls_print_scripts', 'pagelayer_wc_add_scripts' );
79 function pagelayer_wc_add_scripts(){
80 ?>
81 <script>
82
83 // Script to load Shop page when user click woocommerce customizer
84 jQuery( function( $ ) {
85 wp.customize.panel( 'pgl_woocommerce', function( panel ) {
86 panel.expanded.bind( function( isExpanded ) {
87 if ( isExpanded ) {
88 wp.customize.previewer.previewUrl.set( "<?php echo esc_js( wc_get_page_permalink( 'shop' ) ); ?>" );
89 }
90 } );
91 } );
92 wp.customize.section( 'pgl_woo_cart_page', function( section ) {
93 section.expanded.bind( function( isExpanded ) {
94 if( isExpanded ){
95 wp.customize.previewer.previewUrl.set( "<?php echo esc_js( wc_get_page_permalink( 'cart' ) ); ?>" );
96 }
97 } );
98 } );
99 wp.customize.section( 'pgl_woo_checkout', function( section ) {
100 section.expanded.bind( function( isExpanded ) {
101 if ( isExpanded ) {
102 wp.customize.previewer.previewUrl.set( "<?php echo esc_js( wc_get_page_permalink( 'checkout' ) ); ?>" );
103 }
104 } );
105 } );
106 wp.customize.section( 'pgl_woo_myaccount_page', function( section ) {
107 section.expanded.bind( function( isExpanded ) {
108 if ( isExpanded ) {
109 wp.customize.previewer.previewUrl.set( "<?php echo esc_js( wc_get_page_permalink( 'myaccount' ) ); ?>" );
110 }
111 } );
112 } );
113 wp.customize.section( 'pgl_woo_product_catalog', function( section ) {
114 section.expanded.bind( function( isExpanded ) {
115 if ( isExpanded ) {
116 wp.customize.previewer.previewUrl.set( "<?php echo esc_js( wc_get_page_permalink( 'shop' ) ); ?>" );
117 }
118 } );
119 } );
120 wp.customize.section( 'pgl_woo_general', function( section ) {
121 section.expanded.bind( function( isExpanded ) {
122 if ( isExpanded ) {
123 wp.customize.previewer.previewUrl.set( "<?php echo esc_js( wc_get_page_permalink( 'shop' ) ); ?>" );
124 }
125 } );
126 } );
127 });
128 </script>
129 <?php
130 }
131 function pagelayer_parse_customize_styles($val, $rule, $unit = 'px'){
132
133 $parse = str_replace(array('{{val}}', '{{color}}', '{{unit}}'), array($val, pagelayer_sanitize_global_color($val), $unit), $rule);
134 $parse = rtrim( trim($parse), ';' );
135
136 return $parse;
137 }
138
139 add_action( 'wp_head', 'pagelayer_woocommerce_styles', 1000 );
140 function pagelayer_woocommerce_styles(){
141 global $pagelayer;
142
143 // Get the option defaults
144 $options = pagelayer_get_customize_options();
145 $modes = array('desktop', 'tablet', 'mobile');
146 $css = array();
147
148 $woo_styles = array(
149 'woo_notice_bg_color' => array(
150 '.woocommerce-store-notice.demo_store' => 'background-color: {{color}}',
151 ),
152 'woo_notice_color' => array(
153 '.woocommerce-store-notice.demo_store' => 'color: {{color}}',
154 ),
155 'woo_notice_a_color' => array(
156 '.woocommerce-store-notice.demo_store a' => 'color: {{color}}',
157 ),
158 'woo_notice_a_hover_color' => array(
159 '.woocommerce-store-notice.demo_store a:hover' => 'color: {{color}}',
160 ),
161 'woo_myaccount_padding' => array(
162 'body.woocommerce-account main.site-main' => array(
163 'top' => 'padding-top: {{val}}{{unit}};',
164 'right' => 'padding-right: {{val}}{{unit}};',
165 'bottom' => 'padding-bottom: {{val}}{{unit}};',
166 'left' => 'padding-left: {{val}}{{unit}};'
167 )
168 ),
169 'woo_checkout_padding' => array(
170 'body.woocommerce-checkout main.site-main' => array(
171 'top' => 'padding-top: {{val}}{{unit}};',
172 'right' => 'padding-right: {{val}}{{unit}};',
173 'bottom' => 'padding-bottom: {{val}}{{unit}};',
174 'left' => 'padding-left: {{val}}{{unit}};'
175 )
176 ),
177 'woo_cart_padding' => array(
178 'body.woocommerce-cart main.site-main' => array(
179 'top' => 'padding-top: {{val}}{{unit}};',
180 'right' => 'padding-right: {{val}}{{unit}};',
181 'bottom' => 'padding-bottom: {{val}}{{unit}};',
182 'left' => 'padding-left: {{val}}{{unit}};'
183 )
184 ),
185 'woo_product_padding' => array(
186 'body.single-product main.site-main' => array(
187 'top' => 'padding-top: {{val}}{{unit}};',
188 'right' => 'padding-right: {{val}}{{unit}};',
189 'bottom' => 'padding-bottom: {{val}}{{unit}};',
190 'left' => 'padding-left: {{val}}{{unit}};'
191 )
192 ),
193 'woo_product_cat_padding' => array(
194 'body.post-type-archive-product .site-main' => array(
195 'top' => 'padding-top: {{val}}{{unit}};',
196 'right' => 'padding-right: {{val}}{{unit}};',
197 'bottom' => 'padding-bottom: {{val}}{{unit}};',
198 'left' => 'padding-left: {{val}}{{unit}};'
199 )
200 ),
201 'woo_menu_cart_color' => array(
202 'li.cart-customlocation span.dashicons-cart' => 'color: {{color}};',
203 ),
204 'woo_menu_cart_number_color' => array(
205 'li.cart-customlocation span.dashicons-cart + sup' => 'color: {{color}};',
206 )
207 );
208
209 $woo_styles = apply_filters('pagelayer_wc_styles_array', $woo_styles);
210
211 // Apply customizer css
212 foreach($woo_styles as $key => $rules){
213
214 $value = pagelayer_isset($options, $key);
215
216 if(empty($value) && $value != '0'){
217 continue;
218 }
219
220 foreach($rules as $sel => $rule){
221
222 // Is not reponsive or not variable value?
223 if(!is_array($value)){
224 $css['desktop'][$sel][] = pagelayer_parse_customize_styles($value, $rule);
225 continue;
226 }
227
228 // If unit exists
229 $unit = !empty($value['unit'])? $value['unit'] : 'px';
230
231 // Parse in array if responsive rule in string
232 $rule = (array) $rule;
233
234 foreach($rule as $kk => $_rule){
235
236 // Is not reponsive or not variable value?
237 if(isset($value[$kk]) && !is_array($value[$kk])){
238
239 if(empty($value[$kk]) && $value[$kk] != '0'){
240 continue;
241 }
242
243 $css['desktop'][$sel][] = pagelayer_parse_customize_styles($value[$kk], $_rule, $unit);
244 }
245
246 foreach($modes as $mode){
247
248 // First level responsive key
249 if(isset($value[$mode])){
250
251 // Responsive without variable
252 $mode_val = is_numeric($kk) ? $value[$mode] : (isset($value[$mode][$kk]) ? $value[$mode][$kk] : null) ;
253
254
255 if(empty($mode_val) && $mode_val != '0'){
256 continue;
257 }
258
259 $css[$mode][$sel][] = pagelayer_parse_customize_styles($mode_val, $_rule, $unit);
260
261 // We are already in responsive mode
262 continue;
263 }
264
265 // Second level responsive key like font size
266 if(!isset($value[$kk][$mode]) || empty($value[$kk][$mode]) && $value[$kk][$mode] != '0'){
267 continue;
268 }
269
270 $css[$mode][$sel][] = pagelayer_parse_customize_styles($value[$kk][$mode], $_rule, $unit);
271 }
272 }
273 }
274 }
275
276 // Create css
277 $screen_css = array('desktop' => '', 'tablet' => '', 'mobile' => '');
278 foreach($css as $mode => $_css){
279 foreach($_css as $selector => $val){
280 $parsr_style = $selector.'{'.implode(';', $val)."}\n";
281 $screen_css[$mode] .= $parsr_style;
282 }
283 }
284
285 $styles = '<style id="pagelayer-woocommerce-styles" type="text/css">'.PHP_EOL;
286 $styles .= $screen_css['desktop'];
287
288 if(!empty($screen_css['woo_product_image_width'])){
289 $styles .= '@media(min-width: 902px) {.woocommerce #content div.product div.images, .woocommerce div.product div.images, .woocommerce-page #content div.product div.images, .woocommerce-page div.product div.images{
290 width: '.$options['woo_product_image_width'].'% !important;
291 }
292 .woocommerce #content div.product div.summary, .woocommerce div.product div.summary, .woocommerce-page #content div.product div.summary, .woocommerce-page div.product div.summary{
293 width: calc(96% - '.$options['woo_product_image_width'].'%) !important;
294 }}';
295 }
296
297 if(!empty($screen_css['tablet'])){
298 $styles .= '@media(max-width: ' . $pagelayer->settings['tablet_breakpoint'] . 'px) {'.$screen_css['tablet'].'}'.PHP_EOL;
299 }
300
301 if(!empty($screen_css['mobile'])){
302 $styles .= '@media(max-width: ' . $pagelayer->settings['mobile_breakpoint'] . 'px) {'.$screen_css['mobile'].'}';
303 }
304
305 $styles .= '</style>';
306
307 echo $styles;
308 }
309
310 // Get Option Values
311 function pagelayer_get_customize_options(){
312 return get_option('pagelayer_customizer_options', array());
313 }
314
315 add_action( 'customize_register', 'pagelayer_woo_customize_register', 11 );
316 function pagelayer_woo_customize_register( $wp_customize ) {
317
318 //Pagelayer + WooCommerce Panel
319 $wp_customize->add_panel( 'pgl_woocommerce', array(
320 'priority' => 10,
321 'title' => __('Pagelayer + WooCommerce'),
322 ) );
323
324 // Add Store Notice Section
325 $wp_customize->get_section( 'woocommerce_store_notice' )->description = '<strong><a href="customize.php?autofocus[section]=pgl_woo_store_notice">'.__('Click here') .'</a> '. __('to change color scheme of store notice') .'</strong>';
326
327 // Add Store Notice Section
328 $wp_customize->add_section( 'pgl_woo_store_notice', array(
329 'panel' => 'pgl_woocommerce',
330 'priority' => 1,
331 'title' => __('Store Notice'),
332 'description' => '<strong><a href="customize.php?autofocus[section]=woocommerce_store_notice">'.__('Click here') .'</a> '. __('to enable the store notice') .'</strong>',
333 )
334 );
335
336 // Adds Customizer settings
337 $wp_customize->add_setting( 'pagelayer_customizer_options[woo_notice_bg_color]', array(
338 'type' => 'option',
339 'capability' => 'edit_theme_options',
340 'transport' => 'refresh',
341 )
342 );
343
344 $wp_customize->add_control( new Pagelayer_Customize_Alpha_Color_Control( $wp_customize, 'pagelayer_customizer_options[woo_notice_bg_color]', array(
345 'label' => __('Background Color'),
346 'section' => 'pgl_woo_store_notice',
347 'priority' => 1
348 ) )
349 );
350
351 // Adds Customizer settings
352 $wp_customize->add_setting( 'pagelayer_customizer_options[woo_notice_color]', array(
353 'type' => 'option',
354 'capability' => 'edit_theme_options',
355 'transport' => 'refresh',
356 )
357 );
358
359 $wp_customize->add_control( new Pagelayer_Customize_Alpha_Color_Control( $wp_customize, 'pagelayer_customizer_options[woo_notice_color]', array(
360 'label' => __('Text Color'),
361 'section' => 'pgl_woo_store_notice',
362 'priority' => 1
363 ) )
364 );
365
366 // Adds Customizer settings
367 $wp_customize->add_setting( 'pagelayer_customizer_options[woo_notice_a_color]', array(
368 'type' => 'option',
369 'capability' => 'edit_theme_options',
370 'transport' => 'refresh',
371 )
372 );
373
374 $wp_customize->add_control( new Pagelayer_Customize_Alpha_Color_Control( $wp_customize, 'pagelayer_customizer_options[woo_notice_a_color]', array(
375 'label' => __('Link Color'),
376 'section' => 'pgl_woo_store_notice',
377 'priority' => 1
378 ) )
379 );
380
381 // Adds Customizer settings
382 $wp_customize->add_setting( 'pagelayer_customizer_options[woo_notice_a_hover_color]', array(
383 'type' => 'option',
384 'capability' => 'edit_theme_options',
385 'transport' => 'refresh',
386 )
387 );
388
389 $wp_customize->add_control( new Pagelayer_Customize_Alpha_Color_Control( $wp_customize, 'pagelayer_customizer_options[woo_notice_a_hover_color]', array(
390 'label' => __('Link Hover Color'),
391 'section' => 'pgl_woo_store_notice',
392 'priority' => 1
393 ) )
394 );
395
396 // Add Store Notice Section
397 $wp_customize->add_section( 'pgl_woo_general', array(
398 'panel' => 'pgl_woocommerce',
399 'title' => __('General'),
400 'priority' => 2,
401 )
402 );
403
404 // Adds Customizer settings
405 $wp_customize->add_setting( 'pagelayer_customizer_options[woo_star_rating_color]', array(
406 'type' => 'option',
407 'capability' => 'edit_theme_options',
408 'transport' => 'refresh',
409 )
410 );
411
412 $wp_customize->add_setting( 'pagelayer_lable_menu_cart', array(
413 'capability' => 'edit_theme_options',
414 ));
415
416 $wp_customize->add_control( new Pagelayer_Customize_Control(
417 $wp_customize, 'pagelayer_lable_menu_cart', array(
418 'type' => 'hidden',
419 'section' => 'pgl_woo_general',
420 'description' => __('<div class="pagelayer-customize-heading"><div>Cart Icon on Menu</div></div>', 'pagelayer'),
421 'li_class' => 'pagelayer-accordion-tab',
422 'priority' => 9
423 )
424 ));
425
426 // Adds Customizer settings
427 $wp_customize->add_setting( 'pagelayer_customizer_options[woo_enable_menu_cart]', array(
428 'type' => 'option',
429 'capability' => 'edit_theme_options',
430 'transport' => 'refresh',
431 )
432 );
433
434 $wp_customize->add_control( new Pagelayer_Custom_Control( $wp_customize, 'pagelayer_customizer_options[woo_enable_menu_cart]', array(
435 'type' => 'checkbox',
436 'label' => __('Show Cart Icon On Primary Menu'),
437 'section' => 'pgl_woo_general',
438 'priority' => 9
439 ))
440 );
441
442 // Adds Customizer settings
443 $wp_customize->add_setting( 'pagelayer_customizer_options[woo_menu_cart_color]', array(
444 'type' => 'option',
445 'capability' => 'edit_theme_options',
446 'transport' => 'refresh'
447 )
448 );
449
450 $wp_customize->add_control( new Pagelayer_Customize_Alpha_Color_Control( $wp_customize, 'pagelayer_customizer_options[woo_menu_cart_color]', array(
451 'label' => __('Icon Color'),
452 'section' => 'pgl_woo_general',
453 'priority' => 10,
454 ) )
455 );
456
457 // Adds Customizer settings
458 $wp_customize->add_setting( 'pagelayer_customizer_options[woo_menu_cart_number_color]', array(
459 'type' => 'option',
460 'capability' => 'edit_theme_options',
461 'transport' => 'refresh'
462 )
463 );
464
465 $wp_customize->add_control( new Pagelayer_Customize_Alpha_Color_Control( $wp_customize, 'pagelayer_customizer_options[woo_menu_cart_number_color]', array(
466 'label' => __('Cart Numbers Color'),
467 'section' => 'pgl_woo_general',
468 'priority' => 10,
469 ) )
470 );
471
472 // Shop Page Section
473 $wp_customize->add_section( 'pgl_woo_product_catalog', array(
474 'panel' => 'pgl_woocommerce',
475 'title' => __('Product Catalog'),
476 'priority' => 4,
477 )
478 );
479
480 // Register the WooCommerce Default Padding
481 pagelayer_register_padding_customizer_control($wp_customize, array(
482 'control' => 'pagelayer_customizer_options',
483 'control_array_sufix' => 'woo_product_cat_padding',
484 'section' => 'pgl_woo_product_catalog',
485 'label' => __( 'Padding', 'pagelayer' ),
486 'capability' => 'edit_theme_options',
487 'setting_type' => 'option',
488 'transport' => 'refresh',
489 'default' => '',
490 'units' => ['px', 'em', '%'],
491 'responsive' => 1,
492 'priority' => 1
493 ), true);
494
495 // Single Product Page Sections
496 $wp_customize->add_section( 'pgl_woo_single_product', array(
497 'panel' => 'pgl_woocommerce',
498 'title' => __('Single Product'),
499 'priority' => 5,
500 )
501 );
502
503 // Register the WooCommerce single page Padding
504 pagelayer_register_padding_customizer_control($wp_customize, array(
505 'control' => 'pagelayer_customizer_options',
506 'control_array_sufix' => 'woo_product_padding',
507 'section' => 'pgl_woo_single_product',
508 'label' => __( 'Padding', 'pagelayer' ),
509 'capability' => 'edit_theme_options',
510 'setting_type' => 'option',
511 'transport' => 'refresh',
512 'default' => '',
513 'units' => ['px', 'em', '%'],
514 'responsive' => 1,
515 'priority' => 1
516 ), true);
517
518 // Single Product Page Breadcrumb Enabler
519 $wp_customize->add_setting( 'pagelayer_customizer_options[woo_disable_breadcrumb]', array(
520 'type' => 'option',
521 'capability' => 'edit_theme_options',
522 'transport' => 'refresh',
523 )
524 );
525
526 $wp_customize->add_control( new Pagelayer_Custom_Control( $wp_customize, 'pagelayer_customizer_options[woo_disable_breadcrumb]', array(
527 'type' => 'checkbox',
528 'label' => __('Disable Breadcrumb'),
529 'section' => 'pgl_woo_single_product',
530 'priority' => 5
531 ))
532 );
533
534 // Cart page settings
535 $wp_customize->add_section( 'pgl_woo_cart_page', array(
536 'panel' => 'pgl_woocommerce',
537 'title' => __('Cart'),
538 'priority' => 7,
539 )
540 );
541
542 pagelayer_register_padding_customizer_control($wp_customize, array(
543 'control' => 'pagelayer_customizer_options',
544 'control_array_sufix' => 'woo_cart_padding',
545 'section' => 'pgl_woo_cart_page',
546 'label' => __( 'Padding', 'pagelayer' ),
547 'capability' => 'edit_theme_options',
548 'setting_type' => 'option',
549 'transport' => 'refresh',
550 'default' => '',
551 'units' => ['px', 'em', '%'],
552 'responsive' => 1,
553 'priority' => 1
554 ), true);
555
556 // cross-sells disable
557 $wp_customize->add_setting( 'pagelayer_customizer_options[woo_disable_cross_sells]', array(
558 'type' => 'option',
559 'capability' => 'edit_theme_options',
560 'transport' => 'refresh',
561 )
562 );
563
564 $wp_customize->add_control( new Pagelayer_Custom_Control( $wp_customize, 'pagelayer_customizer_options[woo_disable_cross_sells]', array(
565 'type' => 'checkbox',
566 'label' => __('Disable Cross-sells'),
567 'section' => 'pgl_woo_cart_page',
568 'priority' => 2
569 ))
570 );
571
572 // Checkout Page Section
573 $wp_customize->add_section( 'pgl_woo_checkout', array(
574 'panel' => 'pgl_woocommerce',
575 'title' => __('Checkout'),
576 'priority' => 9,
577 )
578 );
579
580 // Checkout page settings
581 pagelayer_register_padding_customizer_control($wp_customize, array(
582 'control' => 'pagelayer_customizer_options',
583 'control_array_sufix' => 'woo_checkout_padding',
584 'section' => 'pgl_woo_checkout',
585 'label' => __( 'Padding', 'pagelayer' ),
586 'capability' => 'edit_theme_options',
587 'setting_type' => 'option',
588 'transport' => 'refresh',
589 'default' => '',
590 'units' => ['px', 'em', '%'],
591 'responsive' => 1,
592 'priority' => 1
593 ), true);
594
595 $wp_customize->add_setting( 'pagelayer_customizer_options[woo_disable_order_note]', array(
596 'type' => 'option',
597 'capability' => 'edit_theme_options',
598 'transport' => 'refresh',
599 )
600 );
601
602 $wp_customize->add_control( new Pagelayer_Custom_Control( $wp_customize, 'pagelayer_customizer_options[woo_disable_order_note]', array(
603 'type' => 'checkbox',
604 'label' => __('Disable Order Note'),
605 'section' => 'pgl_woo_checkout',
606 'priority' => 2
607 ))
608 );
609
610 $wp_customize->add_setting( 'pagelayer_customizer_options[woo_disable_coupon_field]', array(
611 'type' => 'option',
612 'capability' => 'edit_theme_options',
613 'transport' => 'refresh',
614 )
615 );
616
617 $wp_customize->add_control( new Pagelayer_Custom_Control( $wp_customize, 'pagelayer_customizer_options[woo_disable_coupon_field]', array(
618 'type' => 'checkbox',
619 'label' => __('Disable Coupon Field'),
620 'section' => 'pgl_woo_checkout',
621 'priority' => 3
622 ))
623 );
624
625 // My Account Page Section
626 $wp_customize->add_section( 'pgl_woo_myaccount_page', array(
627 'panel' => 'pgl_woocommerce',
628 'title' => __('My Account'),
629 'priority' => 10,
630 )
631 );
632
633 // My Account page settings
634 pagelayer_register_padding_customizer_control($wp_customize, array(
635 'control' => 'pagelayer_customizer_options',
636 'control_array_sufix' => 'woo_myaccount_padding',
637 'section' => 'pgl_woo_myaccount_page',
638 'label' => __( 'Padding', 'pagelayer' ),
639 'capability' => 'edit_theme_options',
640 'setting_type' => 'option',
641 'transport' => 'refresh',
642 'default' => '',
643 'units' => ['px', 'em', '%'],
644 'responsive' => 1,
645 'priority' => 1
646 ), true);
647 }
648
649 // Get product
650 function pagelayer_get_product(){
651
652 $_product = wc_get_product();
653
654 if(!empty($_product)){
655 return $_product;
656 }
657
658 $post = $GLOBALS['post'];
659
660 if( !wp_doing_ajax() && $post->post_type != 'pagelayer-template'){
661 return false;
662 }
663
664 $products = get_posts([
665 'post_type' => 'product',
666 'numberposts' => '1',
667 ]);
668
669 if(empty($products)){
670 return false;
671 }
672
673 $_product = wc_get_product($products[0]->ID);
674
675 return $_product;
676 }
677
678 // Load Product configurations to edit the product template
679 add_action( 'template_redirect', 'pagelayer_load_product_template');
680 function pagelayer_load_product_template($post = []){
681 global $pagelayer, $product;
682
683 if(!$post){
684 $post = $GLOBALS['post'];
685 }
686
687 if(!class_exists('woocommerce') || empty($post->post_type) || $post->post_type != 'pagelayer-template' || !isset($pagelayer->builder['singular_templates']['Products']) ){
688 return false;
689 }
690
691 $products = array_keys($pagelayer->builder['singular_templates']['Products']);
692 $conditions = get_post_meta( $post->ID, 'pagelayer_template_conditions', true );
693
694 $is_product_temp = false;
695
696 foreach( $conditions as $condi ){
697 if(in_array($condi['sub_template'], $products)){
698 $is_product_temp = true;
699 }
700 }
701
702 if(!$is_product_temp){
703 return false;
704 }
705
706 // Add WooCommerce Class to body
707 add_filter('body_class', function($classes){
708 $classes[] = 'woocommerce';
709 return $classes;
710 });
711
712 $product = pagelayer_get_product();
713
714 //pagelayer_print($product);
715
716 wp_enqueue_script( 'wc-single-product' );
717 wp_enqueue_style( 'wc-single-product' );
718
719 // Load woocomerce css and js
720 if ( current_theme_supports( 'wc-product-gallery-zoom' ) ) {
721 wp_enqueue_script( 'zoom' );
722 }
723
724 if ( current_theme_supports( 'wc-product-gallery-slider' ) ) {
725 wp_enqueue_script( 'flexslider' );
726 }
727
728 if ( current_theme_supports( 'wc-product-gallery-lightbox' ) ) {
729 wp_enqueue_script( 'photoswipe-ui-default' );
730 wp_enqueue_style( 'photoswipe-default-skin' );
731 add_action( 'wp_footer', 'woocommerce_photoswipe' );
732 }
733
734 wp_enqueue_style( 'photoswipe' );
735 wp_enqueue_style( 'photoswipe-default-skin' );
736 wp_enqueue_style( 'photoswipe-default-skin' );
737 wp_enqueue_style( 'woocommerce_prettyPhoto_css' );
738 }
739
740 // Apply filter to load extra woocommerce settings
741 do_action('pagelayer_after_wc_customization');
742