PluginProbe
SellKit – Funnel builder and checkout optimizer for WooCommerce to sell more, faster / trunk
SellKit – Funnel builder and checkout optimizer for WooCommerce to sell more, faster vtrunk
2.6.0 trunk 1.1.0 1.1.4 1.2.1 1.2.2 1.2.3 1.2.5 1.2.9 1.3.1 1.3.2 1.5.0 1.5.1 1.5.4 1.5.7 1.5.8 1.5.9 1.6.2 1.6.5 1.6.8 1.7.2 1.7.4 1.7.5 1.7.9 1.8.1 All 42 releases
sellkit / includes / elementor / base / upsell-base-widget.php

upsell-base-widget.php in SellKit – Funnel builder and checkout optimizer for WooCommerce to sell more, faster trunk, at includes/elementor/base/upsell-base-widget.php

71 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 defined( 'ABSPATH' ) || die();
4
5 /**
6 * Sellkit Elementor Upsell Base Widget.
7 *
8 * @since 1.1.0
9 */
10 abstract class Sellkit_Elementor_Upsell_Base_Widget extends Sellkit_Elementor_Base_Widget {
11
12 /**
13 * Step data which was sent from funnel.
14 *
15 * @var array
16 */
17 public $step_data;
18
19 /**
20 * Sellkit_Elementor_Upsell_Base_Widget constructor.
21 *
22 * @since 1.1.0
23 * @param array $data Data.
24 * @param null $args Args.
25 */
26 public function __construct( $data = [], $args = null ) {
27 parent::__construct( $data, $args );
28
29 global $post;
30
31 if ( empty( $post->ID ) ) {
32 return;
33 }
34
35 $this->step_data = get_post_meta( $post->ID, 'step_data', true );
36 }
37
38 /**
39 * It's used for getting product object data which was defined in funnels panel.
40 *
41 * @return false|WC_Product
42 */
43 public function get_product_object() {
44 if ( empty( $this->step_data['data']['products']['list'] ) || count( $this->step_data['data']['products']['list'] ) === 0 ) {
45 return false;
46 }
47
48 $products = $this->step_data['data']['products']['list'];
49 $product_id = key( $products );
50
51 return wc_get_product( $product_id );
52 }
53
54 /**
55 * Only show the widgets when the page is an upsell page.
56 *
57 * @return bool
58 */
59 public function show_in_panel() {
60 if ( empty( $this->step_data['type']['key'] ) ) {
61 return false;
62 }
63
64 if ( 'upsell' !== $this->step_data['type']['key'] && 'downsell' !== $this->step_data['type']['key'] ) {
65 return false;
66 }
67
68 return true;
69 }
70 }
71