PluginProbe
WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell / 3.11.1
WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell v3.11.1
3.13.3 3.13.2 3.13.1 3.13.0 3.12.13 3.12.12 3.12.11 3.12.10 3.12.9 3.12.8 3.12.7 3.12.6 3.12.5 3.12.4 3.12.3 3.12.1 3.12.2 3.12.0 3.11.1 3.11.0 3.10.9 3.10.8 3.10.7 3.10.6 2.8.16 All 261 releases
wpfunnels / includes / core / widgets / elementor / elements / offer-button.php

offer-button.php in WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell 3.11.1, at includes/core/widgets/elementor/elements/offer-button.php

1,216 lines 37.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace WPFunnels\Widgets\Elementor;
4
5 use Elementor\Widget_Base;
6 use Elementor\Controls_Manager;
7 use Elementor\Group_Control_Border;
8 use Elementor\Group_Control_Typography;
9 use Elementor\Group_Control_Box_Shadow;
10 use Elementor\Group_Control_Text_Shadow;
11 use Elementor\Icons_Manager;
12 use WPFunnels\Wpfnl_functions;
13 if (!defined('ABSPATH')) {
14 exit;
15 } // Exit if accessed directly
16
17 /**
18 * Funnel sell accept button
19 *
20 * @since 1.0.0
21 */
22 class Offer_Button extends Widget_Base
23 {
24
25
26 /**
27 * Register the widget controls.
28 *
29 * Adds different input fields to allow the user to change and Wpvrize the widget settings.
30 *
31 * @since 1.0.0
32 *
33 * @access protected
34 */
35 protected function init_controls() {
36 if ( version_compare(ELEMENTOR_VERSION, '3.1.0', '>=') ) {
37 $this->register_controls();
38 } else {
39 $this->_register_controls();
40 }
41 }
42
43
44
45 /**
46 * Retrieve the widget name.
47 *
48 * @return string Widget name.
49 * @since 1.0.0
50 *
51 * @access public
52 *
53 */
54 public function get_name()
55 {
56 return 'wpfnl-offer';
57 }
58
59 /**
60 * Retrieve the widget title.
61 *
62 * @return string Widget title.
63 * @since 1.0.0
64 *
65 * @access public
66 *
67 */
68 public function get_title()
69 {
70 return __('Offer Button', 'wpfnl');
71 }
72
73 /**
74 * Retrieve the widget icon.
75 *
76 * @return string Widget icon.
77 * @since 1.0.0
78 *
79 * @access public
80 *
81 */
82 public function get_icon()
83 {
84 return 'icon-wpfnl sell-accept';
85 }
86
87 /**
88 * Retrieve the list of categories the widget belongs to.
89 *
90 * Used to determine where to display the widget in the editor.
91 *
92 * Note that currently Elementor supports only one category.
93 * When multiple categories passed, Elementor uses the first one.
94 *
95 * @return array Widget categories.
96 * @since 1.0.0
97 *
98 * @access public
99 *
100 */
101 public function get_categories()
102 {
103 return ['wp-funnel'];
104 }
105
106 /**
107 * Retrieve the list of scripts the widget depended on.
108 *
109 * Used to set scripts dependencies required to run the widget.
110 *
111 * @return array Widget scripts dependencies.
112 * @since 1.0.0
113 *
114 * @access public
115 *
116 */
117 public function get_script_depends()
118 {
119 return ['upsell-downsell-widget'];
120 }
121
122 /**
123 * Get button sizes.
124 *
125 * Retrieve an array of button sizes for the button widget.
126 *
127 * @return array An array containing button sizes.
128 * @since 1.0.0
129 * @access public
130 * @static
131 *
132 */
133 public static function get_button_sizes()
134 {
135 return [
136 'xs' => __('Extra Small', 'wpfnl-pro'),
137 'sm' => __('Small', 'wpfnl-pro'),
138 'md' => __('Medium', 'wpfnl-pro'),
139 'lg' => __('Large', 'wpfnl-pro'),
140 'xl' => __('Extra Large', 'wpfnl-pro'),
141 ];
142 }
143
144 /**
145 * Register the widget controls.
146 * @since 1.0.0
147 *
148 * @access protected
149 */
150 protected function _register_controls()
151 {
152 //----content funtion----
153
154 $this->register_dynamic_data_template_content();
155 $this->register_offer_button_content();
156
157 //----style funtion----
158 $this->register_dynamic_data_template_style();
159 $this->register_offer_button_style();
160
161 }
162
163
164 /**
165 * Register the widget controls.
166 * @since 1.0.0
167 *
168 * @access protected
169 */
170 protected function register_controls()
171 {
172 //----content funtion----
173 $this->register_offer_button_content();
174 $this->register_dynamic_data_template_content();
175
176 //----style funtion----
177 $this->register_dynamic_data_template_style();
178 $this->register_offer_button_style();
179 }
180
181
182 /**
183 * Register Dynamic Data Template content Control.
184 *
185 * @since x.x.x
186 * @access protected
187 */
188 protected function register_dynamic_data_template_content(){
189
190
191 $this->start_controls_section(
192 'dynamic_data_template_content',
193 array(
194 'label' => __('Template Content', 'wpfnl-pro'),
195 'condition' => array(
196 'show_product_data' => 'yes',
197 'offer_type' => 'accept',
198 ),
199 )
200 );
201
202 $this->add_control(
203 'dynamic_data_template_layout',
204 [
205 'label' => __('Select Template Style ', 'wpfnl-pro'),
206 'type' => \Elementor\Controls_Manager::SELECT,
207 'default' => 'style1',
208 'options' => [
209 'style1' => __('Left Image Right Content', 'wpfnl-pro'),
210 'style2' => __('Left Content Right Image', 'wpfnl-pro'),
211 'style3' => __('Top Image Bottom Content', 'wpfnl-pro'),
212 ],
213
214 ]
215 );
216
217 $this->end_controls_section();
218 }
219
220 /**
221 * Register Dynamic Data Template Style Control.
222 *
223 * @since x.x.x
224 * @access protected
225 */
226 protected function register_dynamic_data_template_style(){
227
228 $this->start_controls_section(
229 'dynamic_data_template_style',
230 [
231 'label' => __('Template Style', 'wpfnl-pro'),
232 'tab' => Controls_Manager::TAB_STYLE,
233 'condition' => array(
234 'show_product_data' => 'yes',
235 'offer_type' => 'accept',
236 ),
237 ]
238 );
239
240 // ----Template Layout Style-----
241 $this->add_control(
242 'template_layout_style',
243 [
244 'label' => __('Layout Style', 'wpfnl-pro'),
245 'type' => Controls_Manager::HEADING,
246 'label_block' => true,
247 ]
248 );
249
250
251 //-----left column for style-1------
252 $this->add_responsive_control(
253 'template_left_col_width',
254 [
255 'label' => esc_html__( 'Image Column Width', 'wpfnl-pro' ),
256 'type' => \Elementor\Controls_Manager::SLIDER,
257 'size_units' => [ 'px', '%' ],
258 'range' => [
259 'px' => [
260 'min' => 0,
261 'max' => 1920,
262 'step' => 1,
263 ],
264 '%' => [
265 'min' => 0,
266 'max' => 100,
267 ],
268 ],
269 'default' => [
270 'unit' => '%',
271 'size' => '',
272 ],
273 'selectors' => [
274 '{{WRAPPER}} .dynamic-offer-template-default .template-left' => 'width: {{SIZE}}{{UNIT}};',
275 ],
276 ]
277 );
278
279 $this->add_responsive_control(
280 'template_right_col_width',
281 [
282 'label' => esc_html__( 'Content Column Width', 'wpfnl-pro' ),
283 'type' => \Elementor\Controls_Manager::SLIDER,
284 'size_units' => [ 'px', '%' ],
285 'range' => [
286 'px' => [
287 'min' => 0,
288 'max' => 1920,
289 'step' => 1,
290 ],
291 '%' => [
292 'min' => 0,
293 'max' => 100,
294 ],
295 ],
296 'default' => [
297 'unit' => '%',
298 'size' => '',
299 ],
300 'selectors' => [
301 '{{WRAPPER}} .dynamic-offer-template-default .template-right' => 'width: {{SIZE}}{{UNIT}};',
302 ],
303 ]
304 );
305
306 $this->add_responsive_control(
307 'template_col_gutter_width',
308 [
309 'label' => esc_html__( 'Column Gutter Width', 'wpfnl-pro' ),
310 'type' => \Elementor\Controls_Manager::SLIDER,
311 'size_units' => [ 'px', '%' ],
312 'range' => [
313 'px' => [
314 'min' => 0,
315 'max' => 100,
316 'step' => 1,
317 ],
318 '%' => [
319 'min' => 0,
320 'max' => 100,
321 ],
322 ],
323 'default' => [
324 'unit' => 'px',
325 'size' => '',
326 ],
327 'selectors' => [
328 '{{WRAPPER}} .dynamic-offer-template-default .template-right' => 'padding-left: {{SIZE}}{{UNIT}};',
329 ],
330 'condition' => array(
331 'dynamic_data_template_layout[value]' => 'style1',
332 ),
333 ]
334 );
335
336 //--when template style-2 select then this control will show---
337 $this->add_responsive_control(
338 'template_col_right_gutter_width',
339 [
340 'label' => esc_html__( 'Column Gutter Width', 'wpfnl-pro' ),
341 'type' => \Elementor\Controls_Manager::SLIDER,
342 'size_units' => [ 'px', '%' ],
343 'range' => [
344 'px' => [
345 'min' => 0,
346 'max' => 100,
347 'step' => 1,
348 ],
349 '%' => [
350 'min' => 0,
351 'max' => 100,
352 ],
353 ],
354 'default' => [
355 'unit' => 'px',
356 'size' => '',
357 ],
358 'selectors' => [
359 '{{WRAPPER}} .dynamic-offer-template-default .template-right' => 'padding-right: {{SIZE}}{{UNIT}};',
360 ],
361 'condition' => array(
362 'dynamic_data_template_layout[value]' => 'style2',
363 ),
364 ]
365 );
366
367 //--when template style-3 select then this control will show---
368 $this->add_responsive_control(
369 'template_col_top_gutter_width',
370 [
371 'label' => esc_html__( 'Column Gutter Width', 'wpfnl-pro' ),
372 'type' => \Elementor\Controls_Manager::SLIDER,
373 'size_units' => [ 'px', '%' ],
374 'range' => [
375 'px' => [
376 'min' => 0,
377 'max' => 100,
378 'step' => 1,
379 ],
380 '%' => [
381 'min' => 0,
382 'max' => 100,
383 ],
384 ],
385 'default' => [
386 'unit' => 'px',
387 'size' => '',
388 ],
389 'selectors' => [
390 '{{WRAPPER}} .dynamic-offer-template-default .template-right' => 'padding-top: {{SIZE}}{{UNIT}};',
391 ],
392 'condition' => array(
393 'dynamic_data_template_layout[value]' => 'style3',
394 ),
395 ]
396 );
397
398 $this->add_responsive_control(
399 'template_layout_radius',
400 [
401 'label' => __('Radius', 'wpfnl-pro'),
402 'type' => Controls_Manager::DIMENSIONS,
403 'size_units' => ['px', 'em', '%'],
404 'selectors' => [
405 '{{WRAPPER}} .dynamic-offer-template-default' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
406 ],
407
408 ]
409 );
410
411 $this->add_group_control(
412 \Elementor\Group_Control_Box_Shadow::get_type(),
413 [
414 'name' => 'template_layout_shadow',
415 'label' => __( 'Box Shadow', 'wpfnl-pro' ),
416 'selector' => '{{WRAPPER}} .dynamic-offer-template-default',
417 ]
418 );
419
420 $this->add_responsive_control(
421 'template_layout_padding',
422 [
423 'label' => __('Padding', 'wpfnl-pro'),
424 'type' => Controls_Manager::DIMENSIONS,
425 'size_units' => ['px', 'em', '%'],
426 'selectors' => [
427 '{{WRAPPER}} .dynamic-offer-template-default' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
428 ],
429 ]
430 );
431
432 $this->add_responsive_control(
433 'template_layout_margin',
434 [
435 'label' => __('Margin', 'wpfnl-pro'),
436 'type' => Controls_Manager::DIMENSIONS,
437 'size_units' => ['px', 'em', '%'],
438 'selectors' => [
439 '{{WRAPPER}} .dynamic-offer-template-default' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
440 ],
441 'separator' => 'after',
442 ]
443 );
444
445 // ----Template Content Style-----
446 $this->add_control(
447 'template_content_heading',
448 [
449 'label' => __('Template Image Style', 'wpfnl-pro'),
450 'type' => Controls_Manager::HEADING,
451 'label_block' => true,
452 ]
453 );
454
455 $this->add_responsive_control(
456 'template_image_width',
457 [
458 'label' => esc_html__( 'Image Width', 'wpfnl-pro' ),
459 'type' => \Elementor\Controls_Manager::SLIDER,
460 'size_units' => [ 'px', '%' ],
461 'range' => [
462 'px' => [
463 'min' => 0,
464 'max' => 1920,
465 'step' => 1,
466 ],
467 '%' => [
468 'min' => 0,
469 'max' => 100,
470 ],
471 ],
472 'default' => [
473 'unit' => '%',
474 'size' => '',
475 ],
476 'selectors' => [
477 '{{WRAPPER}} .dynamic-offer-template-default .product-img img' => 'width: {{SIZE}}{{UNIT}};',
478 ],
479 ]
480 );
481
482 $this->add_responsive_control(
483 'template_image_radius',
484 [
485 'label' => __('Image Radius', 'wpfnl-pro'),
486 'type' => Controls_Manager::DIMENSIONS,
487 'size_units' => ['px', 'em', '%'],
488 'selectors' => [
489 '{{WRAPPER}} .dynamic-offer-template-default .product-img img' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
490 ],
491 'separator' => 'after',
492
493 ]
494 );
495
496 $this->add_control(
497 'template_heading_style',
498 [
499 'label' => __('Heading Style', 'wpfnl-pro'),
500 'type' => Controls_Manager::HEADING,
501 'label_block' => true,
502 ]
503 );
504 $this->add_control(
505 'template_heading_color',
506 [
507 'label' => __('Color', 'wpfnl-pro'),
508 'type' => Controls_Manager::COLOR,
509 'default' => '',
510 'selectors' => [
511 '{{WRAPPER}} .dynamic-offer-template-default .template-content .template-product-title' => 'color: {{VALUE}};',
512 ],
513 ]
514 );
515 $this->add_group_control(
516 Group_Control_Typography::get_type(),
517 [
518 'name' => 'template_heading_typography',
519 'label' => 'Typography',
520 'selector' => '{{WRAPPER}} .dynamic-offer-template-default .template-content .template-product-title',
521 ]
522 );
523 $this->add_responsive_control(
524 'template_heading_margin',
525 [
526 'label' => __('Margin', 'wpfnl-pro'),
527 'type' => Controls_Manager::DIMENSIONS,
528 'size_units' => ['px', 'em', '%'],
529 'selectors' => [
530 '{{WRAPPER}} .dynamic-offer-template-default .template-content .template-product-title' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
531 ],
532 'separator' => 'after',
533 ]
534 );
535
536
537 // ----Template description Style-----
538 $this->add_control(
539 'template_description_style',
540 [
541 'label' => __('Description Style', 'wpfnl-pro'),
542 'type' => Controls_Manager::HEADING,
543 'label_block' => true,
544 ]
545 );
546
547 $this->add_control(
548 'template_description_color',
549 [
550 'label' => __('Color', 'wpfnl-pro'),
551 'type' => Controls_Manager::COLOR,
552 'default' => '',
553 'selectors' => [
554 '{{WRAPPER}} .dynamic-offer-template-default .template-content .template-product-description' => 'color: {{VALUE}};',
555 ],
556 ]
557 );
558 $this->add_group_control(
559 Group_Control_Typography::get_type(),
560 [
561 'name' => 'template_description_typography',
562 'label' => 'Typography',
563 'selector' => '{{WRAPPER}} .dynamic-offer-template-default .template-content .template-product-description',
564 ]
565 );
566 $this->add_responsive_control(
567 'template_description_margin',
568 [
569 'label' => __('Margin', 'wpfnl-pro'),
570 'type' => Controls_Manager::DIMENSIONS,
571 'size_units' => ['px', 'em', '%'],
572 'selectors' => [
573 '{{WRAPPER}} .dynamic-offer-template-default .template-content .template-product-description' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
574 ],
575 'separator' => 'after',
576 ]
577 );
578
579
580 // ----Template price Style-----
581 $this->add_control(
582 'template_price_style',
583 [
584 'label' => __('Price Style', 'wpfnl-pro'),
585 'type' => Controls_Manager::HEADING,
586 'label_block' => true,
587 ]
588 );
589
590 $this->add_control(
591 'template_price_color',
592 [
593 'label' => __('Regular Price Color', 'wpfnl-pro'),
594 'type' => Controls_Manager::COLOR,
595 'default' => '',
596 'selectors' => [
597 '{{WRAPPER}} .dynamic-offer-template-default #wpfnl-offerbtn-wrapper .wpfnl-offer-product-price del bdi, .dynamic-offer-template-default #wpfnl-offerbtn-wrapper .wpfnl-offer-product-price del' => 'color: {{VALUE}};',
598 ],
599 ]
600 );
601 $this->add_control(
602 'template_discount_price_color',
603 [
604 'label' => __('Discount Price Color', 'wpfnl-pro'),
605 'type' => Controls_Manager::COLOR,
606 'default' => '',
607 'selectors' => [
608 '{{WRAPPER}} .dynamic-offer-template-default #wpfnl-offerbtn-wrapper .wpfnl-offer-product-price bdi' => 'color: {{VALUE}};',
609 ],
610 ]
611 );
612 $this->add_group_control(
613 Group_Control_Typography::get_type(),
614 [
615 'name' => 'template_discount_price_typography',
616 'label' => 'Discount Price Typography',
617 'selector' => '{{WRAPPER}} .dynamic-offer-template-default #wpfnl-offerbtn-wrapper .wpfnl-offer-product-price bdi',
618 ]
619 );
620 $this->add_group_control(
621 Group_Control_Typography::get_type(),
622 [
623 'name' => 'template_price_typography',
624 'label' => 'Regular Price Typography',
625 'selector' => '{{WRAPPER}} .dynamic-offer-template-default #wpfnl-offerbtn-wrapper .wpfnl-offer-product-price del bdi,
626 {{WRAPPER}} .dynamic-offer-template-default #wpfnl-offerbtn-wrapper .wpfnl-offer-product-price',
627 ]
628 );
629 $this->add_responsive_control(
630 'template_price_margin',
631 [
632 'label' => __('Margin', 'wpfnl-pro'),
633 'type' => Controls_Manager::DIMENSIONS,
634 'size_units' => ['px', 'em', '%'],
635 'selectors' => [
636 '{{WRAPPER}} .dynamic-offer-template-default #wpfnl-offerbtn-wrapper .wpfnl-offer-product-price' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
637 ],
638 'separator' => 'after',
639 ]
640 );
641
642 $this->end_controls_section();
643 }
644
645
646 /**
647 * Register Offer Button Content Control.
648 *
649 * @since x.x.x
650 * @access protected
651 */
652 protected function register_offer_button_content(){
653 $this->start_controls_section(
654 'section_button',
655 array(
656 'label' => __('Upsell/Downsell', 'wpfnl-pro'),
657 )
658 );
659
660 $this->add_control(
661 'offer_button_type',
662 [
663 'label' => __('Select button type', 'wpfnl-pro'),
664 'type' => \Elementor\Controls_Manager::SELECT,
665 'default' => 'upsell',
666 'options' => [
667 'upsell' => __('Upsell', 'wpfnl-pro'),
668 'downsell' => __('Downsell', 'wpfnl-pro'),
669 ],
670 ]
671 );
672
673 $this->add_control(
674 'offer_type',
675 [
676 'label' => __('Select button action', 'wpfnl-pro'),
677 'type' => \Elementor\Controls_Manager::SELECT,
678 'default' => 'accept',
679 'options' => array(
680 'accept' => __('Accept', 'wpfnl-pro'),
681 'reject' => __('Reject', 'wpfnl-pro'),
682 )
683 ]
684 );
685
686 $this->add_control(
687 'text',
688 [
689 'label' => __('Text', 'wpfnl-pro'),
690 'type' => Controls_Manager::TEXT,
691 'default' => __('Accept Offer', 'wpfnl-pro'),
692 'placeholder' => __('Accept Offer', 'wpfnl-pro'),
693 'separator' => 'before',
694 ]
695 );
696
697 $this->add_responsive_control(
698 'align',
699 [
700 'label' => __('Alignment', 'wpfnl-pro'),
701 'type' => Controls_Manager::CHOOSE,
702 'options' => [
703 'left' => [
704 'title' => __('Left', 'wpfnl-pro'),
705 'icon' => 'fa fa-align-left',
706 ],
707 'center' => [
708 'title' => __('Center', 'wpfnl-pro'),
709 'icon' => 'fa fa-align-center',
710 ],
711 'right' => [
712 'title' => __('Right', 'wpfnl-pro'),
713 'icon' => 'fa fa-align-right',
714 ],
715 'justify' => [
716 'title' => __('Justified', 'wpfnl-pro'),
717 'icon' => 'fa fa-align-justify',
718 ],
719 ],
720 'prefix_class' => 'elementor%s-align-',
721 'default' => '',
722 ]
723 );
724
725 $this->add_responsive_control(
726 'size',
727 [
728 'label' => __('Size', 'wpfnl-pro'),
729 'type' => Controls_Manager::SELECT,
730 'default' => 'sm',
731 'options' => self::get_button_sizes(),
732 ]
733 );
734
735 $this->add_control(
736 'upsell_downsell_button_icon',
737 [
738 'label' => __('Icon', 'wpfnl'),
739 'type' => Controls_Manager::ICONS,
740 'fa4compatibility' => 'icon',
741 ]
742 );
743
744 $this->add_control(
745 'upsell_downsell_button_icon_align',
746 [
747 'label' => __('Icon Position', 'wpfnl-pro'),
748 'type' => Controls_Manager::SELECT,
749 'default' => 'left',
750 'options' => array(
751 'left' => __('Before', 'wpfnl-pro'),
752 'right' => __('After', 'wpfnl-pro'),
753 ),
754 'condition' => array(
755 'upsell_downsell_button_icon[value]!' => '',
756 ),
757 ]
758 );
759
760 $this->add_control(
761 'upsell_downsell_button_icon_indent',
762 [
763 'label' => __('Icon Spacing', 'wpfnl'),
764 'type' => \Elementor\Controls_Manager::SLIDER,
765 'range' => [
766 'px' => [
767 'max' => 50,
768 ],
769 ],
770 'condition' => [
771 'upsell_downsell_button_icon!' => '',
772 ],
773 'selectors' => [
774 '{{WRAPPER}} .elementor-button .elementor-align-icon-right' => 'margin-left: {{SIZE}}{{UNIT}};',
775 '{{WRAPPER}} .elementor-button .elementor-align-icon-left' => 'margin-right: {{SIZE}}{{UNIT}};',
776 ],
777 ]
778 );
779
780 $this->add_control(
781 'view',
782 [
783 'label' => __('View', 'wpfnl-pro'),
784 'type' => Controls_Manager::HIDDEN,
785 'default' => 'traditional',
786 ]
787 );
788
789 $get_product_type = Wpfnl_functions::get_offer_product_type( get_the_ID() );
790
791 if( $get_product_type == 'variable' || $get_product_type == 'variable-subscription' ){
792 $this->add_control(
793 'variation_tbl_title',
794 [
795 'label' => __('Variation Table Title', 'wpfnl-pro'),
796 'type' => Controls_Manager::TEXTAREA,
797 'separator' => 'before',
798 'condition' => [
799 'offer_type' => 'accept',
800 ],
801 ]
802 );
803 }
804
805 $this->add_control(
806 'show_product_price',
807 [
808 'label' => esc_html__( 'Show Product Price', 'wpfnl-pro' ),
809 'type' => \Elementor\Controls_Manager::SWITCHER,
810 'label_on' => esc_html__( 'Show', 'wpfnl-pro' ),
811 'label_off' => esc_html__( 'Hide', 'wpfnl-pro' ),
812 'return_value' => 'yes',
813 'default' => 'no',
814 'condition' => [
815 'offer_type' => 'accept',
816 ],
817 ]
818 );
819
820 $this->add_control(
821 'product_price_alignment',
822 [
823 'label' => __('Price Alignment ', 'wpfnl-pro'),
824 'type' => \Elementor\Controls_Manager::SELECT,
825 'default' => '',
826 'options' => [
827 '' => __('On The Left Of Button', 'wpfnl-pro'),
828 'price-right' => __('On The Right Of Button', 'wpfnl-pro'),
829 'price-top' => __('Above The Button', 'wpfnl-pro'),
830 'price-bottom' => __('Below The Button', 'wpfnl-pro'),
831 ],
832 'condition' => [
833 'show_product_price' => 'yes',
834 ],
835
836 ]
837 );
838
839 $funnel_id = get_post_meta( get_the_ID(), '_funnel_id', true );
840 $is_gbf = get_post_meta( $funnel_id, 'is_global_funnel', true );
841
842 if( 'yes' === $is_gbf ){
843 $this->add_control(
844 'show_product_data',
845 [
846 'label' => esc_html__( 'Show Product Data', 'wpfnl-pro' ),
847 'type' => \Elementor\Controls_Manager::SWITCHER,
848 'label_on' => esc_html__( 'Show', 'wpfnl-pro' ),
849 'label_off' => esc_html__( 'Hide', 'wpfnl-pro' ),
850 'return_value' => 'yes',
851 'default' => 'off',
852 'condition' => [
853 'offer_type' => 'accept',
854 ],
855 ]
856 );
857 }
858
859 $this->end_controls_section();
860
861 }
862
863
864 /**
865 * Register Offer Button Style Control.
866 *
867 * @since x.x.x
868 * @access protected
869 */
870 protected function register_offer_button_style(){
871
872 $this->start_controls_section(
873 'button_section_style',
874 [
875 'label' => __('Button', 'wpfnl-pro'),
876 'tab' => Controls_Manager::TAB_STYLE,
877 ]
878 );
879
880 $this->add_group_control(
881 Group_Control_Typography::get_type(),
882 [
883 'name' => 'upsell_downsell_button_typography',
884 'label' => 'Typography',
885 'selector' => '{{WRAPPER}} a.elementor-button',
886 ]
887 );
888
889 $this->add_group_control(
890 Group_Control_Text_Shadow::get_type(),
891 [
892 'name' => 'upsell_downsell_button_text_shadow',
893 'selector' => '{{WRAPPER}} a.elementor-button',
894 ]
895 );
896
897 $this->start_controls_tabs('tabs_button_style');
898
899 $this->start_controls_tab(
900 'tab_button_normal',
901 [
902 'label' => __('Normal', 'wpfnl-pro'),
903 ]
904 );
905
906 $this->add_control(
907 'button_text_color',
908 [
909 'label' => __('Text Color', 'wpfnl-pro'),
910 'type' => Controls_Manager::COLOR,
911 'default' => '',
912 'selectors' => [
913 '{{WRAPPER}} a.elementor-button, {{WRAPPER}} .elementor-button' => 'color: {{VALUE}};',
914 ],
915 ]
916 );
917
918 $this->add_control(
919 'background_color',
920 [
921 'label' => __('Background Color', 'wpfnl-pro'),
922 'type' => Controls_Manager::COLOR,
923 'default' => '#61CE70',
924 'selectors' => [
925 '{{WRAPPER}} a.elementor-button, {{WRAPPER}} .elementor-button' => 'background-color: {{VALUE}};',
926 ],
927 ]
928 );
929
930 $this->end_controls_tab();
931
932 $this->start_controls_tab(
933 'tab_button_hover',
934 [
935 'label' => __('Hover', 'wpfnl-pro'),
936 ]
937 );
938
939 $this->add_control(
940 'hover_color',
941 [
942 'label' => __('Text Color', 'wpfnl-pro'),
943 'type' => Controls_Manager::COLOR,
944 'selectors' => [
945 '{{WRAPPER}} a.elementor-button:hover, {{WRAPPER}} .elementor-button:hover' => 'color: {{VALUE}};',
946 ],
947 ]
948 );
949
950 $this->add_control(
951 'button_background_hover_color',
952 [
953 'label' => __('Background Color', 'wpfnl-pro'),
954 'type' => Controls_Manager::COLOR,
955 'selectors' => [
956 '{{WRAPPER}} a.elementor-button:hover, {{WRAPPER}} .elementor-button:hover' => 'background-color: {{VALUE}};',
957 ],
958 ]
959 );
960
961 $this->add_control(
962 'button_hover_border_color',
963 [
964 'label' => __('Border Color', 'wpfnl-pro'),
965 'type' => Controls_Manager::COLOR,
966 'condition' => [
967 'border_border!' => '',
968 ],
969 'selectors' => [
970 '{{WRAPPER}} a.elementor-button:hover, {{WRAPPER}} .elementor-button:hover' => 'border-color: {{VALUE}};',
971 ],
972 ]
973 );
974
975 $this->end_controls_tab();
976
977 $this->end_controls_tabs();
978
979 $this->add_group_control(
980 Group_Control_Border::get_type(),
981 [
982 'name' => 'border',
983 'label' => __('Border', 'wpfnl-pro'),
984 'placeholder' => '1px',
985 'default' => '1px',
986 'selector' => '{{WRAPPER}} .elementor-button',
987 'separator' => 'before',
988 ]
989 );
990
991 $this->add_control(
992 'border_radius',
993 [
994 'label' => __('Border Radius', 'wpfnl-pro'),
995 'type' => Controls_Manager::DIMENSIONS,
996 'size_units' => ['px', '%'],
997 'selectors' => [
998 '{{WRAPPER}} a.elementor-button, {{WRAPPER}} .elementor-button' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
999 ],
1000 ]
1001 );
1002
1003 $this->add_group_control(
1004 Group_Control_Box_Shadow::get_type(),
1005 [
1006 'name' => 'button_box_shadow',
1007 'selector' => '{{WRAPPER}} .elementor-button',
1008 ]
1009 );
1010
1011 $this->add_responsive_control(
1012 'upsell_downsell_padding',
1013 [
1014 'label' => __('Padding', 'wpfnl-pro'),
1015 'type' => Controls_Manager::DIMENSIONS,
1016 'size_units' => ['px', 'em', '%'],
1017 'selectors' => [
1018 '{{WRAPPER}} a.elementor-button, {{WRAPPER}} .elementor-button' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
1019 ],
1020 'separator' => 'before',
1021 ]
1022 );
1023
1024 $this->end_controls_section();
1025
1026 }
1027
1028
1029 public function get_prev_next_link_options()
1030 {
1031 $associate_funnel_id = get_post_meta(get_the_ID(), '_funnel_id', true);
1032 $steps_array = [
1033 'upsell' => 'Upsell',
1034 'downsell' => 'Downsell',
1035 'thankyou' => 'Thankyou'
1036 ];
1037 $option_group = [];
1038 foreach ($steps_array as $key => $value) {
1039 $args = [
1040 'posts_per_page' => -1,
1041 'orderby' => 'date',
1042 'order' => 'DESC',
1043 'post_type' => WPFNL_STEPS_POST_TYPE,
1044 'post_status' => 'publish',
1045 'post__not_in' => [$this->get_id()],
1046 'meta_query' => [
1047 'relation' => 'AND',
1048 [
1049 'key' => '_step_type',
1050 'value' => $key,
1051 'compare' => '=',
1052 ],
1053 [
1054 'key' => '_funnel_id',
1055 'value' => $associate_funnel_id,
1056 'compare' => '=',
1057 ],
1058 ],
1059 ];
1060 $query = new \WP_Query($args);
1061 $steps = $query->posts;
1062 if ($steps) {
1063 foreach ($steps as $s) {
1064 $option_group[$key][] = [
1065 'id' => $s->ID,
1066 'title' => $s->post_title,
1067 ];
1068 }
1069 }
1070 }
1071 return $option_group;
1072 }
1073
1074 /**
1075 * Get all WC products
1076 * @since 1.0.0
1077 *
1078 * @access protected
1079 */
1080 protected function get_products_array()
1081 {
1082 $products = array();
1083 if (in_array('woocommerce/woocommerce.php', WPFNL_ACTIVE_PLUGINS)) {
1084 $ids = wc_get_products(array('return' => 'ids', 'limit' => -1));
1085 if( !empty($ids) ){
1086 foreach ($ids as $id) {
1087 $title = get_the_title($id);
1088 $products[$id] = $title;
1089 }
1090 }
1091 }
1092 return $products;
1093 }
1094
1095 /**
1096 * Get all funnel steps
1097 * @since 1.0.0
1098 *
1099 * @access protected
1100 */
1101 protected function get_steps_array($type = 'upsell')
1102 {
1103 $options = $this->get_prev_next_link_options();
1104 $response = array();
1105 if (isset($options[$type])) {
1106 $prime_data = $options[$type];
1107 foreach ($prime_data as $data) {
1108 $response[$data['id']] = $data['title'];
1109 }
1110 }
1111
1112 return $response;
1113 }
1114
1115 /**
1116 * Render the widget output on the frontend.
1117 *
1118 * Written in PHP and used to generate the final HTML.
1119 *
1120 * @since 1.0.0
1121 *
1122 * @access protected
1123 */
1124 protected function render()
1125 {
1126
1127 $settings = $this->get_settings();
1128 $this->add_render_attribute('wrapper', 'class', 'elementor-button-wrapper');
1129
1130 $this->add_render_attribute('button', 'class', 'elementor-button');
1131 $this->add_render_attribute(
1132 'button',
1133 array(
1134 'id' => ['wpfunnels_'.$settings['offer_button_type'].'_'.$settings['offer_type']],
1135 'class' => [ 'wpfunnels-elementor-widget', 'wpfunnels_offer_button' ],
1136 )
1137 );
1138
1139 if (!empty($settings['size'])) {
1140 $this->add_render_attribute('button', 'class', 'elementor-size-' . $settings['size']);
1141 }
1142
1143 if ( isset($settings['hover_animation']) && $settings['hover_animation']) {
1144 $this->add_render_attribute('button', 'class', 'elementor-animation-' . $settings['hover_animation']);
1145 }
1146 $response = Wpfnl_functions::get_product_data_for_widget( get_the_ID() );
1147 $offer_product = isset($response['offer_product']) && $response['offer_product'] ? $response['offer_product'] : '';
1148 $get_product_type = isset($response['get_product_type']) && $response['get_product_type'] ? $response['get_product_type'] : '';
1149 $is_gbf = isset($response['is_gbf']) && $response['is_gbf'] ? $response['is_gbf'] : '';
1150 $builder = 'elementor';
1151
1152 if( 'yes' == $is_gbf && $settings['show_product_data'] == 'yes' && $settings['offer_type'] == 'accept' ){
1153 require WPFNL_DIR . 'public/modules/dynamic-offer-templates/styles/offer-' . $settings['dynamic_data_template_layout'] . '.php';
1154 }else{
1155 require WPFNL_DIR . 'public/modules/dynamic-offer-templates/elementor/offer-button.php';
1156 }
1157
1158 }
1159
1160 /**
1161 * Render button text.
1162 *
1163 * Render button widget text.
1164 *
1165 * @since 1.5.0
1166 * @access protected
1167 */
1168 protected function render_text()
1169 {
1170 $settings = $this->get_settings();
1171
1172 $migrated = isset($settings['__fa4_migrated']['upsell_downsell_button_icon']);
1173 $is_new = empty($settings['icon']) && Icons_Manager::is_migration_allowed();
1174
1175 if (!$is_new && empty($settings['upsell_downsell_button_icon_align'])) {
1176
1177 $settings['upsell_downsell_button_icon_align'] = $this->get_settings('upsell_downsell_button_icon_align');
1178 }
1179
1180 $this->add_render_attribute([
1181 'content-wrapper' => [
1182 'class' => 'elementor-button-content-wrapper',
1183 ],
1184 'icon-align' => [
1185 'class' => [
1186 'elementor-button-icon',
1187 'elementor-align-icon-' . $settings['upsell_downsell_button_icon_align'],
1188 ],
1189 ],
1190 'text' => [
1191 'class' => 'elementor-button-text',
1192 ],
1193 ]);
1194
1195
1196 $this->add_render_attribute('content-wrapper', 'class', 'elementor-button-content-wrapper');
1197 $this->add_render_attribute('icon-align', 'class', 'elementor-button-icon');
1198
1199 $this->add_render_attribute('text', 'class', 'elementor-button-text');
1200 $this->add_inline_editing_attributes('text', 'none');
1201 ?>
1202 <span <?php echo $this->get_render_attribute_string('content-wrapper'); ?>>
1203 <?php if (!empty($settings['icon']) || !empty($settings['upsell_downsell_button_icon']['value'])) : ?>
1204 <span <?php echo $this->get_render_attribute_string('icon-align'); ?>>
1205 <?php if ($is_new || $migrated) :
1206 Icons_Manager::render_icon($settings['upsell_downsell_button_icon'], ['aria-hidden' => 'true']);
1207 else : ?>
1208 <i class="<?php echo esc_attr($settings['icon']); ?>" aria-hidden="true"></i>
1209 <?php endif; ?>
1210 </span>
1211 <?php endif; ?>
1212 <span <?php echo $this->get_render_attribute_string('text'); ?>><?php echo $settings['text']; ?></span>
1213 </span>
1214 <?php
1215 }
1216 }