PluginProbe
Page Builder: Pagelayer – Drag and Drop website builder / 2.1.6
Page Builder: Pagelayer – Drag and Drop website builder v2.1.6
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.1.6, at main/woocommerce.php

741 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] : $value[$mode][$kk] ;
253
254 if(empty($mode_val) && $mode_val != '0'){
255 continue;
256 }
257
258 $css[$mode][$sel][] = pagelayer_parse_customize_styles($mode_val, $_rule, $unit);
259
260 // We are already in responsive mode
261 continue;
262 }
263
264 // Second level responsive key like font size
265 if(!isset($value[$kk][$mode]) || empty($value[$kk][$mode]) && $value[$kk][$mode] != '0'){
266 continue;
267 }
268
269 $css[$mode][$sel][] = pagelayer_parse_customize_styles($value[$kk][$mode], $_rule, $unit);
270 }
271 }
272 }
273 }
274
275 // Create css
276 $screen_css = array('desktop' => '', 'tablet' => '', 'mobile' => '');
277 foreach($css as $mode => $_css){
278 foreach($_css as $selector => $val){
279 $parsr_style = $selector.'{'.implode(';', $val)."}\n";
280 $screen_css[$mode] .= $parsr_style;
281 }
282 }
283
284 $styles = '<style id="pagelayer-woocommerce-styles" type="text/css">'.PHP_EOL;
285 $styles .= $screen_css['desktop'];
286
287 if(!empty($screen_css['woo_product_image_width'])){
288 $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{
289 width: '.$options['woo_product_image_width'].'% !important;
290 }
291 .woocommerce #content div.product div.summary, .woocommerce div.product div.summary, .woocommerce-page #content div.product div.summary, .woocommerce-page div.product div.summary{
292 width: calc(96% - '.$options['woo_product_image_width'].'%) !important;
293 }}';
294 }
295
296 if(!empty($screen_css['tablet'])){
297 $styles .= '@media(max-width: ' . $pagelayer->settings['tablet_breakpoint'] . 'px) {'.$screen_css['tablet'].'}'.PHP_EOL;
298 }
299
300 if(!empty($screen_css['mobile'])){
301 $styles .= '@media(max-width: ' . $pagelayer->settings['mobile_breakpoint'] . 'px) {'.$screen_css['mobile'].'}';
302 }
303
304 $styles .= '</style>';
305
306 echo $styles;
307 }
308
309 // Get Option Values
310 function pagelayer_get_customize_options(){
311 return get_option('pagelayer_customizer_options', array());
312 }
313
314 add_action( 'customize_register', 'pagelayer_woo_customize_register', 11 );
315 function pagelayer_woo_customize_register( $wp_customize ) {
316
317 //Pagelayer + WooCommerce Panel
318 $wp_customize->add_panel( 'pgl_woocommerce', array(
319 'priority' => 10,
320 'title' => __('Pagelayer + WooCommerce'),
321 ) );
322
323 // Add Store Notice Section
324 $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>';
325
326 // Add Store Notice Section
327 $wp_customize->add_section( 'pgl_woo_store_notice', array(
328 'panel' => 'pgl_woocommerce',
329 'priority' => 1,
330 'title' => __('Store Notice'),
331 'description' => '<strong><a href="customize.php?autofocus[section]=woocommerce_store_notice">'.__('Click here') .'</a> '. __('to enable the store notice') .'</strong>',
332 )
333 );
334
335 // Adds Customizer settings
336 $wp_customize->add_setting( 'pagelayer_customizer_options[woo_notice_bg_color]', array(
337 'type' => 'option',
338 'capability' => 'edit_theme_options',
339 'transport' => 'refresh',
340 )
341 );
342
343 $wp_customize->add_control( new Pagelayer_Customize_Alpha_Color_Control( $wp_customize, 'pagelayer_customizer_options[woo_notice_bg_color]', array(
344 'label' => __('Background Color'),
345 'section' => 'pgl_woo_store_notice',
346 'priority' => 1
347 ) )
348 );
349
350 // Adds Customizer settings
351 $wp_customize->add_setting( 'pagelayer_customizer_options[woo_notice_color]', array(
352 'type' => 'option',
353 'capability' => 'edit_theme_options',
354 'transport' => 'refresh',
355 )
356 );
357
358 $wp_customize->add_control( new Pagelayer_Customize_Alpha_Color_Control( $wp_customize, 'pagelayer_customizer_options[woo_notice_color]', array(
359 'label' => __('Text Color'),
360 'section' => 'pgl_woo_store_notice',
361 'priority' => 1
362 ) )
363 );
364
365 // Adds Customizer settings
366 $wp_customize->add_setting( 'pagelayer_customizer_options[woo_notice_a_color]', array(
367 'type' => 'option',
368 'capability' => 'edit_theme_options',
369 'transport' => 'refresh',
370 )
371 );
372
373 $wp_customize->add_control( new Pagelayer_Customize_Alpha_Color_Control( $wp_customize, 'pagelayer_customizer_options[woo_notice_a_color]', array(
374 'label' => __('Link Color'),
375 'section' => 'pgl_woo_store_notice',
376 'priority' => 1
377 ) )
378 );
379
380 // Adds Customizer settings
381 $wp_customize->add_setting( 'pagelayer_customizer_options[woo_notice_a_hover_color]', array(
382 'type' => 'option',
383 'capability' => 'edit_theme_options',
384 'transport' => 'refresh',
385 )
386 );
387
388 $wp_customize->add_control( new Pagelayer_Customize_Alpha_Color_Control( $wp_customize, 'pagelayer_customizer_options[woo_notice_a_hover_color]', array(
389 'label' => __('Link Hover Color'),
390 'section' => 'pgl_woo_store_notice',
391 'priority' => 1
392 ) )
393 );
394
395 // Add Store Notice Section
396 $wp_customize->add_section( 'pgl_woo_general', array(
397 'panel' => 'pgl_woocommerce',
398 'title' => __('General'),
399 'priority' => 2,
400 )
401 );
402
403 // Adds Customizer settings
404 $wp_customize->add_setting( 'pagelayer_customizer_options[woo_star_rating_color]', array(
405 'type' => 'option',
406 'capability' => 'edit_theme_options',
407 'transport' => 'refresh',
408 )
409 );
410
411 $wp_customize->add_setting( 'pagelayer_lable_menu_cart', array(
412 'capability' => 'edit_theme_options',
413 ));
414
415 $wp_customize->add_control( new Pagelayer_Customize_Control(
416 $wp_customize, 'pagelayer_lable_menu_cart', array(
417 'type' => 'hidden',
418 'section' => 'pgl_woo_general',
419 'description' => __('<div class="pagelayer-customize-heading"><div>Cart Icon on Menu</div></div>', 'pagelayer'),
420 'li_class' => 'pagelayer-accordion-tab',
421 'priority' => 9
422 )
423 ));
424
425 // Adds Customizer settings
426 $wp_customize->add_setting( 'pagelayer_customizer_options[woo_enable_menu_cart]', array(
427 'type' => 'option',
428 'capability' => 'edit_theme_options',
429 'transport' => 'refresh',
430 )
431 );
432
433 $wp_customize->add_control( new Pagelayer_Custom_Control( $wp_customize, 'pagelayer_customizer_options[woo_enable_menu_cart]', array(
434 'type' => 'checkbox',
435 'label' => __('Show Cart Icon On Primary Menu'),
436 'section' => 'pgl_woo_general',
437 'priority' => 9
438 ))
439 );
440
441 // Adds Customizer settings
442 $wp_customize->add_setting( 'pagelayer_customizer_options[woo_menu_cart_color]', array(
443 'type' => 'option',
444 'capability' => 'edit_theme_options',
445 'transport' => 'refresh'
446 )
447 );
448
449 $wp_customize->add_control( new Pagelayer_Customize_Alpha_Color_Control( $wp_customize, 'pagelayer_customizer_options[woo_menu_cart_color]', array(
450 'label' => __('Icon Color'),
451 'section' => 'pgl_woo_general',
452 'priority' => 10,
453 ) )
454 );
455
456 // Adds Customizer settings
457 $wp_customize->add_setting( 'pagelayer_customizer_options[woo_menu_cart_number_color]', array(
458 'type' => 'option',
459 'capability' => 'edit_theme_options',
460 'transport' => 'refresh'
461 )
462 );
463
464 $wp_customize->add_control( new Pagelayer_Customize_Alpha_Color_Control( $wp_customize, 'pagelayer_customizer_options[woo_menu_cart_number_color]', array(
465 'label' => __('Cart Numbers Color'),
466 'section' => 'pgl_woo_general',
467 'priority' => 10,
468 ) )
469 );
470
471 // Shop Page Section
472 $wp_customize->add_section( 'pgl_woo_product_catalog', array(
473 'panel' => 'pgl_woocommerce',
474 'title' => __('Product Catalog'),
475 'priority' => 4,
476 )
477 );
478
479 // Register the WooCommerce Default Padding
480 pagelayer_register_padding_customizer_control($wp_customize, array(
481 'control' => 'pagelayer_customizer_options',
482 'control_array_sufix' => 'woo_product_cat_padding',
483 'section' => 'pgl_woo_product_catalog',
484 'label' => __( 'Padding', 'pagelayer' ),
485 'capability' => 'edit_theme_options',
486 'setting_type' => 'option',
487 'transport' => 'refresh',
488 'default' => '',
489 'units' => ['px', 'em', '%'],
490 'responsive' => 1,
491 'priority' => 1
492 ), true);
493
494 // Single Product Page Sections
495 $wp_customize->add_section( 'pgl_woo_single_product', array(
496 'panel' => 'pgl_woocommerce',
497 'title' => __('Single Product'),
498 'priority' => 5,
499 )
500 );
501
502 // Register the WooCommerce single page Padding
503 pagelayer_register_padding_customizer_control($wp_customize, array(
504 'control' => 'pagelayer_customizer_options',
505 'control_array_sufix' => 'woo_product_padding',
506 'section' => 'pgl_woo_single_product',
507 'label' => __( 'Padding', 'pagelayer' ),
508 'capability' => 'edit_theme_options',
509 'setting_type' => 'option',
510 'transport' => 'refresh',
511 'default' => '',
512 'units' => ['px', 'em', '%'],
513 'responsive' => 1,
514 'priority' => 1
515 ), true);
516
517 // Single Product Page Breadcrumb Enabler
518 $wp_customize->add_setting( 'pagelayer_customizer_options[woo_disable_breadcrumb]', array(
519 'type' => 'option',
520 'capability' => 'edit_theme_options',
521 'transport' => 'refresh',
522 )
523 );
524
525 $wp_customize->add_control( new Pagelayer_Custom_Control( $wp_customize, 'pagelayer_customizer_options[woo_disable_breadcrumb]', array(
526 'type' => 'checkbox',
527 'label' => __('Disable Breadcrumb'),
528 'section' => 'pgl_woo_single_product',
529 'priority' => 5
530 ))
531 );
532
533 // Cart page settings
534 $wp_customize->add_section( 'pgl_woo_cart_page', array(
535 'panel' => 'pgl_woocommerce',
536 'title' => __('Cart'),
537 'priority' => 7,
538 )
539 );
540
541 pagelayer_register_padding_customizer_control($wp_customize, array(
542 'control' => 'pagelayer_customizer_options',
543 'control_array_sufix' => 'woo_cart_padding',
544 'section' => 'pgl_woo_cart_page',
545 'label' => __( 'Padding', 'pagelayer' ),
546 'capability' => 'edit_theme_options',
547 'setting_type' => 'option',
548 'transport' => 'refresh',
549 'default' => '',
550 'units' => ['px', 'em', '%'],
551 'responsive' => 1,
552 'priority' => 1
553 ), true);
554
555 // cross-sells disable
556 $wp_customize->add_setting( 'pagelayer_customizer_options[woo_disable_cross_sells]', array(
557 'type' => 'option',
558 'capability' => 'edit_theme_options',
559 'transport' => 'refresh',
560 )
561 );
562
563 $wp_customize->add_control( new Pagelayer_Custom_Control( $wp_customize, 'pagelayer_customizer_options[woo_disable_cross_sells]', array(
564 'type' => 'checkbox',
565 'label' => __('Disable Cross-sells'),
566 'section' => 'pgl_woo_cart_page',
567 'priority' => 2
568 ))
569 );
570
571 // Checkout Page Section
572 $wp_customize->add_section( 'pgl_woo_checkout', array(
573 'panel' => 'pgl_woocommerce',
574 'title' => __('Checkout'),
575 'priority' => 9,
576 )
577 );
578
579 // Checkout page settings
580 pagelayer_register_padding_customizer_control($wp_customize, array(
581 'control' => 'pagelayer_customizer_options',
582 'control_array_sufix' => 'woo_checkout_padding',
583 'section' => 'pgl_woo_checkout',
584 'label' => __( 'Padding', 'pagelayer' ),
585 'capability' => 'edit_theme_options',
586 'setting_type' => 'option',
587 'transport' => 'refresh',
588 'default' => '',
589 'units' => ['px', 'em', '%'],
590 'responsive' => 1,
591 'priority' => 1
592 ), true);
593
594 $wp_customize->add_setting( 'pagelayer_customizer_options[woo_disable_order_note]', array(
595 'type' => 'option',
596 'capability' => 'edit_theme_options',
597 'transport' => 'refresh',
598 )
599 );
600
601 $wp_customize->add_control( new Pagelayer_Custom_Control( $wp_customize, 'pagelayer_customizer_options[woo_disable_order_note]', array(
602 'type' => 'checkbox',
603 'label' => __('Disable Order Note'),
604 'section' => 'pgl_woo_checkout',
605 'priority' => 2
606 ))
607 );
608
609 $wp_customize->add_setting( 'pagelayer_customizer_options[woo_disable_coupon_field]', array(
610 'type' => 'option',
611 'capability' => 'edit_theme_options',
612 'transport' => 'refresh',
613 )
614 );
615
616 $wp_customize->add_control( new Pagelayer_Custom_Control( $wp_customize, 'pagelayer_customizer_options[woo_disable_coupon_field]', array(
617 'type' => 'checkbox',
618 'label' => __('Disable Coupon Field'),
619 'section' => 'pgl_woo_checkout',
620 'priority' => 3
621 ))
622 );
623
624 // My Account Page Section
625 $wp_customize->add_section( 'pgl_woo_myaccount_page', array(
626 'panel' => 'pgl_woocommerce',
627 'title' => __('My Account'),
628 'priority' => 10,
629 )
630 );
631
632 // My Account page settings
633 pagelayer_register_padding_customizer_control($wp_customize, array(
634 'control' => 'pagelayer_customizer_options',
635 'control_array_sufix' => 'woo_myaccount_padding',
636 'section' => 'pgl_woo_myaccount_page',
637 'label' => __( 'Padding', 'pagelayer' ),
638 'capability' => 'edit_theme_options',
639 'setting_type' => 'option',
640 'transport' => 'refresh',
641 'default' => '',
642 'units' => ['px', 'em', '%'],
643 'responsive' => 1,
644 'priority' => 1
645 ), true);
646 }
647
648 // Get product
649 function pagelayer_get_product(){
650
651 $_product = wc_get_product();
652
653 if(!empty($_product)){
654 return $_product;
655 }
656
657 $post = $GLOBALS['post'];
658
659 if( !wp_doing_ajax() && $post->post_type != 'pagelayer-template'){
660 return false;
661 }
662
663 $products = get_posts([
664 'post_type' => 'product',
665 'numberposts' => '1',
666 ]);
667
668 if(empty($products)){
669 return false;
670 }
671
672 $_product = wc_get_product($products[0]->ID);
673
674 return $_product;
675 }
676
677 // Load Product configurations to edit the product template
678 add_action( 'template_redirect', 'pagelayer_load_product_template');
679 function pagelayer_load_product_template($post = []){
680 global $pagelayer, $product;
681
682 if(!$post){
683 $post = $GLOBALS['post'];
684 }
685
686 if(!class_exists('woocommerce') || empty($post->post_type) || $post->post_type != 'pagelayer-template' || !isset($pagelayer->builder['singular_templates']['Products']) ){
687 return false;
688 }
689
690 $products = array_keys($pagelayer->builder['singular_templates']['Products']);
691 $conditions = get_post_meta( $post->ID, 'pagelayer_template_conditions', true );
692
693 $is_product_temp = false;
694
695 foreach( $conditions as $condi ){
696 if(in_array($condi['sub_template'], $products)){
697 $is_product_temp = true;
698 }
699 }
700
701 if(!$is_product_temp){
702 return false;
703 }
704
705 // Add WooCommerce Class to body
706 add_filter('body_class', function($classes){
707 $classes[] = 'woocommerce';
708 return $classes;
709 });
710
711 $product = pagelayer_get_product();
712
713 //pagelayer_print($product);
714
715 wp_enqueue_script( 'wc-single-product' );
716 wp_enqueue_style( 'wc-single-product' );
717
718 // Load woocomerce css and js
719 if ( current_theme_supports( 'wc-product-gallery-zoom' ) ) {
720 wp_enqueue_script( 'zoom' );
721 }
722
723 if ( current_theme_supports( 'wc-product-gallery-slider' ) ) {
724 wp_enqueue_script( 'flexslider' );
725 }
726
727 if ( current_theme_supports( 'wc-product-gallery-lightbox' ) ) {
728 wp_enqueue_script( 'photoswipe-ui-default' );
729 wp_enqueue_style( 'photoswipe-default-skin' );
730 add_action( 'wp_footer', 'woocommerce_photoswipe' );
731 }
732
733 wp_enqueue_style( 'photoswipe' );
734 wp_enqueue_style( 'photoswipe-default-skin' );
735 wp_enqueue_style( 'photoswipe-default-skin' );
736 wp_enqueue_style( 'woocommerce_prettyPhoto_css' );
737 }
738
739 // Apply filter to load extra woocommerce settings
740 do_action('pagelayer_after_wc_customization');
741