PluginProbe
SellKit – Funnel builder and checkout optimizer for WooCommerce to sell more, faster / 1.7.4
SellKit – Funnel builder and checkout optimizer for WooCommerce to sell more, faster v1.7.4
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 / modules / order-details / items / item-base.php

item-base.php in SellKit – Funnel builder and checkout optimizer for WooCommerce to sell more, faster 1.7.4, at includes/elementor/modules/order-details/items/item-base.php

342 lines 6.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Add Item Base.
4 *
5 * @package JupiterX_Core\sellkit
6 * @since 1.1.0
7 */
8
9 namespace Sellkit\Elementor\Modules\Order_Details\Items;
10
11 defined( 'ABSPATH' ) || die();
12
13 use Elementor\Settings;
14 use Elementor\Plugin as Elementor;
15 /**
16 * Item Base.
17 *
18 * An abstract class to register new order details item.
19 *
20 * @since 1.1.0
21 * @abstract
22 */
23 abstract class Item_Base {
24
25 /**
26 * The funnel object.
27 *
28 * @since 1.1.0
29 * @var \Sellkit_Funnel Sellki funnel.
30 */
31 public $funnel;
32
33 /**
34 * Item_Base constructor.
35 *
36 * @NEXT
37 */
38 public function __construct() {
39 $this->funnel = sellkit_funnel();
40
41 add_action( 'woocommerce_thankyou', [ $this, 'check_order_page' ] );
42 remove_action( 'woocommerce_thankyou', [ $this, 'check_order_page' ] );
43 }
44
45 /**
46 * Order details widget.
47 *
48 * Holds the Order details widget instance.
49 *
50 * @access public
51 *
52 * @var array
53 */
54 public $widget;
55
56 /**
57 * Item field.
58 *
59 * Holds all the Items attributes.
60 *
61 * @access public
62 *
63 * @var array
64 */
65 public $field;
66
67 /**
68 * Get Item ID.
69 *
70 * Retrieve the Item type.
71 *
72 * @since 1.1.0
73 * @access public
74 *
75 * @return string Item ID.
76 */
77 public function get_id() {
78 return $this->field['_id'];
79 }
80
81 /**
82 * Get item type.
83 *
84 * Retrieve the item type.
85 *
86 * @since 1.1.0
87 * @access public
88 *
89 * @return string Field type.
90 */
91 public function get_type() {
92 return $this->field['type'];
93 }
94
95 /**
96 * Get item label.
97 *
98 * Retrieve the item label.
99 *
100 * @since 1.1.0
101 * @access public
102 *
103 * @return string item label.
104 */
105 public function get_label() {
106 return $this->field['label'];
107 }
108
109 /**
110 * Get item icon.
111 *
112 * Retrieve the item icon.
113 *
114 * @since 1.1.0
115 * @access public
116 *
117 * @return string item icon.
118 */
119 public function get_icon() {
120 return $this->field['detail_item_icon'];
121 }
122
123 /**
124 * Get item class.
125 *
126 * Retrieve the item class.
127 *
128 * @since 1.1.0
129 * @access public
130 *
131 * @return string item class.
132 */
133 public function get_class() {
134 return 'sellkit-field';
135 }
136
137 /**
138 * Get item width.
139 *
140 * Retrieve the item width.
141 *
142 * @since 1.1.0
143 * @access public
144 *
145 * @return integer Field width.
146 */
147 public function get_width() {
148 return $this->field['detail_item_width'];
149 }
150
151 /**
152 * Get item title.
153 *
154 * Retrieve the item title.
155 *
156 * @since 1.1.0
157 * @access public
158 *
159 * @return string Field title.
160 */
161 public function get_title() {
162 return '';
163 }
164
165
166 /**
167 * Render item.
168 *
169 * Render item label and content.
170 *
171 * @since 1.1.0
172 * @access public
173 *
174 * @param object $widget Widget instance.
175 * @param array $field Field.
176 */
177 public function render( $widget, $field ) {
178 $this->widget = $widget;
179 $this->field = $field;
180
181 $this->add_field_render_attribute();
182 $this->widget->add_render_attribute(
183 'item-group-' . $this->get_id(),
184 [
185 'id' => 'sellkit-order-details-items-group-' . $this->get_id(),
186 'class' => 'order_details woocommerce-order-overview__' . $this->get_class_name() . ' ' . $this->get_class_name() . ' sellkit-flex-wrap sellkit-item-type-' . $this->get_type() . ' sellkit-order-details-items-group elementor-column elementor-col-' . $this->get_width(),
187 ]
188 );
189
190 if ( ! empty( $field['width_tablet'] ) ) {
191 $this->widget->add_render_attribute(
192 'item-group-' . $this->get_id(),
193 'class',
194 'elementor-md-' . $field['width_tablet']
195 );
196 }
197
198 if ( ! empty( $field['width_mobile'] ) ) {
199 $this->widget->add_render_attribute(
200 'item-group-' . $this->get_id(),
201 'class',
202 'elementor-sm-' . $field['width_mobile']
203 );
204 }
205 ?>
206 <li <?php echo $this->widget->get_render_attribute_string( 'item-group-' . $this->get_id() ); ?>>
207 <div class="order-details-heading-group">
208 <?php
209 $this->render_icon();
210 $this->render_label();
211 ?>
212 </div>
213 <?php
214 $this->check_order_page();
215 ?>
216 </li>
217 <?php
218 }
219
220 /**
221 * Add render attribute.
222 *
223 * Add render attributes for each item based on the settings.
224 *
225 * @since 1.1.0
226 * @access public
227 */
228 public function add_field_render_attribute() {
229 $title = $this->get_title();
230
231 $attributes = [
232 'id' => 'order-details-item-' . $this->get_id(),
233 'class' => $this->get_class(),
234 ];
235
236 if ( ! empty( $title ) ) {
237 $attributes['title'] = $title;
238 }
239
240 $this->widget->add_render_attribute( 'order-details-item-' . $this->get_id(), $attributes );
241 }
242
243 /**
244 * Render label.
245 *
246 * Render the label for each item.
247 *
248 * @since 1.1.0
249 * @access public
250 */
251 public function render_label() {
252
253 if ( empty( $this->get_label() ) ) {
254 return;
255 }
256 ?>
257 <h5
258 class="sellkit-order-details-heading">
259 <?php echo $this->get_label(); ?>
260 </h5>
261 <?php
262 }
263
264 /**
265 * Render icon.
266 *
267 * Render the icon for each item.
268 *
269 * @since 1.1.0
270 * @access public
271 */
272 public function render_icon() {
273 if ( empty( $this->get_icon() ) ) {
274 return;
275 }
276 ?>
277 <span class="sellkit-order-details-icon">
278 <?php Elementor::$instance->icons_manager->render_icon( $this->get_icon() ); ?>
279 </span>
280 <?php
281 }
282
283 /**
284 * Check order page.
285 *
286 * @since 1.1.0
287 * @access public
288 */
289 public function check_order_page() {
290 // phpcs:ignore
291 $key = isset( $_GET['order-key'] ) ? sanitize_text_field( $_GET['order-key'] ) : false;
292 $id = wc_get_order_id_by_order_key( $key );
293
294 if ( $key && ! empty( $this->funnel->funnel_id ) ) {
295 $order = wc_get_order( $id );
296 $order_data = $order->get_data();
297
298 $this->render_content( $order_data );
299 }
300 }
301
302 /**
303 * Render content.
304 *
305 * Render the item content.
306 *
307 * @since 1.1.0
308 * @access public
309 * @abstract
310 *
311 * @return string The field content.
312 * @param object $order_data Order data.
313 */
314 abstract public function render_content( $order_data );
315
316 /**
317 * Render dummy content.
318 *
319 * Render the item dummy content.
320 *
321 * @since 1.1.0
322 * @access public
323 * @abstract
324 *
325 * @return string The field dummy content.
326 */
327 abstract public function render_dummy_content();
328
329 /**
330 * Render class name.
331 *
332 * Render the item class name.
333 *
334 * @since 1.1.0
335 * @access public
336 * @abstract
337 *
338 * @return string The field class name.
339 */
340 abstract public function get_class_name();
341 }
342