PluginProbe
SellKit – Funnel builder and checkout optimizer for WooCommerce to sell more, faster / 1.2.5
SellKit – Funnel builder and checkout optimizer for WooCommerce to sell more, faster v1.2.5
2.7.0 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 All 43 releases
sellkit / includes / dynamic-keywords / contact-segmentation / contact-base.php

contact-base.php in SellKit – Funnel builder and checkout optimizer for WooCommerce to sell more, faster 1.2.5, at includes/dynamic-keywords/contact-segmentation/contact-base.php

177 lines 2.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Sellkit\Dynamic_Keywords\Contact_Segmentation;
4
5 use Sellkit\Contact_Segmentation\Contact_Data;
6 use Sellkit\Database;
7
8 defined( 'ABSPATH' ) || die();
9
10 /**
11 * Contact segmentation base.
12 *
13 * @since 1.1.0
14 */
15 abstract class Contact_Segmentation_Base {
16
17 /**
18 * Contact segmentation data.
19 *
20 * @var object
21 * @since 1.1.0
22 */
23 public static $contact_segmentation = [];
24
25 /**
26 * Cart items.
27 *
28 * @var object
29 * @since 1.1.0
30 */
31 public static $cart_items = [];
32
33 /**
34 * Alert ID.
35 *
36 * @var integer|null
37 * @since 1.2.1
38 */
39 public static $alert_id = null;
40
41 /**
42 * Constructor.
43 *
44 * @since 1.1.0
45 */
46 public function __construct() {
47 self::$cart_items = ! empty( WC()->session->cart ) ? WC()->session->cart : '';
48 }
49
50 /**
51 * Get shortcode default data.
52 *
53 * @since 1.1.0
54 */
55 public function get_data() {
56 if ( ! class_exists( 'Sellkit\Contact_Segmentation\Contact_Data' ) ) {
57 return;
58 }
59
60 $contact_data = Contact_Data::get_instance();
61
62 if ( empty( $contact_data->get_data() ) ) {
63 return;
64 }
65
66 $this::$contact_segmentation = $contact_data->get_data();
67
68 return $contact_data->get_data();
69 }
70
71 /**
72 * Get shortcode default data.
73 *
74 * @since 1.1.0
75 * @param array $atts shortcode attributes.
76 */
77 public function shortcode_content( $atts ) {
78 $atts = shortcode_atts( [
79 'fallback' => '',
80 ], $atts );
81
82 return $atts['fallback'];
83 }
84
85 /**
86 * Get shortcode default data.
87 *
88 * @since 1.1.0
89 * @param string $type condition slug.
90 */
91 public function get_content_meta( $type ) {
92 if ( is_admin() ) {
93 return;
94 }
95
96 $this::$alert_id = get_query_var( 'alert_id' );
97
98 $alert_meta = get_post_meta( $this::$alert_id, 'conditions', true );
99
100 if ( empty( $alert_meta ) ) {
101 return;
102 }
103
104 foreach ( $alert_meta as $meta ) {
105 if ( in_array( $type, $meta, true ) ) {
106 return $meta['condition_value'];
107 }
108 }
109
110 return [];
111 }
112
113 /**
114 * Check products and categories count.
115 *
116 * @since 1.1.0
117 * @param array $list array of shortcode result.
118 */
119 public function get_result( $list ) {
120 if ( count( $list ) < 4 ) {
121 return $list;
122 }
123
124 $list = array_slice( $list, 0, 4 );
125 $list_last_item = $list[3];
126
127 array_splice( $list, -1, 2, esc_html__( 'And ', 'sellkit' ) );
128
129 array_push( $list, $list_last_item );
130
131 return $list;
132 }
133
134 /**
135 * Get Keywords type.
136 *
137 * @since 1.1.0
138 */
139 public static function get_keywords_type() {
140 return 'contact_segmentation';
141 }
142
143 /**
144 * Get keyword id.
145 *
146 * @since 1.1.0
147 * @access public
148 * @abstract
149 *
150 * @return string
151 */
152 abstract public function get_id();
153
154 /**
155 * Get keyword title.
156 *
157 * @since 1.1.0
158 * @access public
159 * @abstract
160 *
161 * @return string
162 */
163 abstract public function get_title();
164
165 /**
166 * Render content.
167 *
168 * @since 1.1.0
169 * @access public
170 * @param array $atts array of shortcode arguments.
171 * @abstract
172 *
173 * @return string
174 */
175 abstract public function render_content( $atts );
176 }
177