PluginProbe
SellKit – Funnel builder and checkout optimizer for WooCommerce to sell more, faster / 1.5.4
SellKit – Funnel builder and checkout optimizer for WooCommerce to sell more, faster v1.5.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 / accept-reject-button / widgets / accept-reject-button.php

accept-reject-button.php in SellKit – Funnel builder and checkout optimizer for WooCommerce to sell more, faster 1.5.4, at includes/elementor/modules/accept-reject-button/widgets/accept-reject-button.php

464 lines 11.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 use Elementor\Widget_Button;
4 use Elementor\Icons_Manager;
5
6 defined( 'ABSPATH' ) || die();
7
8 class Sellkit_Elementor_Accept_Reject_Button_Widget extends Sellkit_Elementor_Upsell_Base_Widget {
9
10 public static function is_active() {
11 return class_exists( 'woocommerce' );
12 }
13
14 public function get_name() {
15 return 'sellkit-accept-reject-button';
16 }
17
18 public function get_title() {
19 return __( 'Accept/Reject Button', 'sellkit' );
20 }
21
22 public function get_icon() {
23 return 'sellkit-element-icon sellkit-accept-reject-button-icon';
24 }
25
26 protected function register_controls() {
27 $this->register_content_box_controls();
28 $this->register_style_box_controls();
29 }
30
31 /**
32 * Content section controls.
33 *
34 * @since 1.1.0
35 */
36 private function register_content_box_controls() {
37 $this->start_controls_section(
38 'content',
39 [
40 'label' => __( 'Content', 'sellkit' ),
41 'tab' => 'content',
42 ]
43 );
44
45 $this->add_control(
46 'offer_type',
47 [
48 'label' => __( 'Offer Type', 'sellkit' ),
49 'type' => 'select',
50 'default' => 'accept',
51 'options' => [
52 'accept' => __( 'Accept Offer', 'sellkit' ),
53 'reject' => __( 'Reject Offer', 'sellkit' ),
54 ],
55 ]
56 );
57
58 $this->add_control(
59 'title',
60 [
61 'label' => __( 'Title', 'sellkit' ),
62 'default' => __( 'Offer Action', 'sellkit' ),
63 'type' => 'text',
64 ]
65 );
66
67 $this->add_control(
68 'sub_title',
69 [
70 'label' => __( 'Sub Title', 'sellkit' ),
71 'type' => 'text',
72 ]
73 );
74
75 $this->add_responsive_control(
76 'content_align',
77 [
78 'label' => __( 'Alignment', 'sellkit' ),
79 'type' => 'choose',
80 'default' => 'left',
81 'options' => [
82 'left' => [
83 'title' => __( 'Left', 'sellkit' ),
84 'icon' => 'fa fa-align-left',
85 ],
86 'center' => [
87 'title' => __( 'Center', 'sellkit' ),
88 'icon' => 'fa fa-align-center',
89 ],
90 'right' => [
91 'title' => __( 'Right', 'sellkit' ),
92 'icon' => 'fa fa-align-right',
93 ],
94 ],
95 'selectors' => [
96 '{{WRAPPER}} .sellkit-accept-reject-button-widget' => 'text-align: {{VALUE}};',
97 ],
98 ]
99 );
100
101 $this->add_control(
102 'button_size',
103 [
104 'label' => __( 'Size', 'sellkit' ),
105 'type' => 'select',
106 'default' => 'md',
107 'options' => Widget_Button::get_button_sizes(),
108 ]
109 );
110
111 $this->add_control(
112 'selected_icon',
113 [
114 'label' => __( 'Icon', 'elementor' ),
115 'type' => 'icons',
116 'fa4compatibility' => 'icon',
117 'skin' => 'inline',
118 'label_block' => false,
119 ]
120 );
121
122 $this->add_control(
123 'icon_spacing',
124 [
125 'label' => __( 'Icon Spacing', 'sellkit' ),
126 'type' => 'slider',
127 'default' => [
128 'size' => 10,
129 ],
130 'range' => [
131 'px' => [
132 'min' => 0,
133 'max' => 50,
134 ],
135 ],
136 'selectors' => [
137 '{{WRAPPER}} .sellkit-accept-reject-button i' => 'margin-right: {{SIZE}}{{UNIT}};',
138 ],
139 'condition' => [
140 'selected_icon!' => [
141 'value' => '',
142 'library' => '',
143 ],
144 ],
145 ]
146 );
147
148 $this->add_control(
149 'icon_size',
150 [
151 'label' => __( 'Icon Size', 'sellkit' ),
152 'type' => 'slider',
153 'range' => [
154 'px' => [
155 'min' => 0,
156 'max' => 50,
157 ],
158 ],
159 'selectors' => [
160 '{{WRAPPER}} .sellkit-accept-reject-button i' => 'font-size: {{SIZE}}{{UNIT}};',
161 ],
162 'condition' => [
163 'selected_icon!' => [
164 'value' => '',
165 'library' => '',
166 ],
167 ],
168 ]
169 );
170
171 $this->add_control(
172 'title_spacing',
173 [
174 'label' => __( 'Title Spacing', 'sellkit' ),
175 'type' => 'slider',
176 'default' => [
177 'size' => 10,
178 ],
179 'range' => [
180 'px' => [
181 'min' => 0,
182 'max' => 50,
183 ],
184 ],
185 'selectors' => [
186 '{{WRAPPER}} .sellkit-accept-reject-button-title' => 'margin-bottom: {{SIZE}}{{UNIT}};',
187 ],
188 'condition' => [
189 'sub_title!' => '',
190 ],
191 ]
192 );
193
194 $this->end_controls_section();
195 }
196
197 /**
198 * Style section controls.
199 *
200 * @since 1.1.0
201 */
202 private function register_style_box_controls() {
203 $this->start_controls_section(
204 'style',
205 [
206 'label' => __( 'Button', 'sellkit' ),
207 'tab' => 'style',
208 ]
209 );
210
211 $this->add_group_control(
212 'typography',
213 [
214 'name' => 'input_typography',
215 'scheme' => '3',
216 'selector' => '{{WRAPPER}} .sellkit-accept-reject-button-widget .sellkit-accept-reject-button-title',
217 ]
218 );
219
220 $this->add_group_control(
221 'typography',
222 [
223 'name' => 'sub_title_typography',
224 'label' => __( 'Subtitle Typography', 'sellkit' ),
225 'scheme' => '3',
226 'selector' => '{{WRAPPER}} .sellkit-accept-reject-button-widget .sellkit-accept-reject-button .sellkit-accept-reject-button-sub-title',
227 'condition' => [
228 'sub_title!' => '',
229 ],
230 ]
231 );
232
233 $this->add_group_control(
234 'text-shadow',
235 [
236 'name' => 'play_icon_shadow',
237 'fields_options' => [
238 'text_shadow_type' => [
239 'label' => __( 'Text Shadow', 'sellkit' ),
240 ],
241 ],
242 'selector' => '{{WRAPPER}} .sellkit-accept-reject-button-widget .sellkit-accept-reject-button',
243 ]
244 );
245
246 $this->start_controls_tabs( 'tabs_content' );
247
248 $this->start_controls_tab(
249 'tab_content_normal',
250 [
251 'label' => __( 'Normal', 'sellkit' ),
252 ]
253 );
254
255 $this->add_control(
256 'text_color',
257 [
258 'label' => __( 'Text Color', 'sellkit' ),
259 'type' => 'color',
260 'selectors' => [
261 '{{WRAPPER}} .sellkit-accept-reject-button-widget .sellkit-accept-reject-button' => 'color: {{VALUE}} !important;',
262 ],
263 ]
264 );
265
266 $this->add_group_control(
267 'background',
268 [
269 'name' => 'background',
270 'label' => __( 'Background Type', 'sellkit' ),
271 'type' => 'background',
272 'default' => '#635cff',
273 'selector' => '{{WRAPPER}} .sellkit-accept-reject-button-widget .sellkit-accept-reject-button',
274 ]
275 );
276
277 $this->end_controls_tab();
278
279 $this->start_controls_tab(
280 'tab_content_hover',
281 [
282 'label' => __( 'Hover', 'sellkit' ),
283 ]
284 );
285
286 $this->add_control(
287 'hover_text_color',
288 [
289 'label' => __( 'Text Color', 'sellkit' ),
290 'type' => 'color',
291 'selectors' => [
292 '{{WRAPPER}} .sellkit-accept-reject-button-widget .sellkit-accept-reject-button:hover' => 'color: {{VALUE}} !important;',
293 ],
294 ]
295 );
296
297 $this->add_group_control(
298 'background',
299 [
300 'name' => 'hover_background',
301 'label' => __( 'Background Type', 'sellkit' ),
302 'type' => 'background',
303 'selector' => '{{WRAPPER}} .sellkit-accept-reject-button-widget .sellkit-accept-reject-button:hover',
304 ]
305 );
306
307 $this->end_controls_tab();
308
309 $this->end_controls_tabs();
310
311 $this->add_control(
312 'border_separator',
313 [
314 'type' => 'divider',
315 ]
316 );
317
318 $this->add_control(
319 'border_type',
320 [
321 'label' => __( 'Border Type', 'sellkit' ),
322 'type' => 'select',
323 'options' => [
324 '' => __( 'None', 'sellkit' ),
325 'solid' => __( 'Solid', 'sellkit' ),
326 'double' => __( 'Double', 'sellkit' ),
327 'dotted' => __( 'Dotted', 'sellkit' ),
328 'dashed' => __( 'Dashed', 'sellkit' ),
329 'groove' => __( 'Groove', 'sellkit' ),
330 ],
331 'selectors' => [
332 '{{WRAPPER}} .sellkit-accept-reject-button-widget .sellkit-accept-reject-button' => 'border-style: {{VALUE}} !important;',
333 ],
334 ]
335 );
336
337 $this->add_control(
338 'border_color',
339 [
340 'label' => __( 'Border Color', 'sellkit' ),
341 'type' => 'color',
342 'selectors' => [
343 '{{WRAPPER}} .sellkit-accept-reject-button-widget .sellkit-accept-reject-button' => 'border-color: {{VALUE}} !important;',
344 ],
345 'condition' => [
346 'border_type!' => '',
347 ],
348 ]
349 );
350
351 $this->add_responsive_control(
352 'border_width',
353 [
354 'label' => __( 'Border Width', 'sellkit' ),
355 'type' => 'slider',
356 'size_units' => [ 'px' ],
357 'default' => [
358 'size' => 1,
359 ],
360 'range' => [
361 'px' => [
362 'min' => 0,
363 'max' => 100,
364 ],
365 ],
366 'selectors' => [
367 '{{WRAPPER}} .sellkit-accept-reject-button-widget .sellkit-accept-reject-button' => 'border-width: {{SIZE}}{{UNIT}} !important;',
368 ],
369 'condition' => [
370 'border_type!' => '',
371 ],
372 ]
373 );
374
375 $this->add_responsive_control(
376 'border_radius',
377 [
378 'label' => __( 'Border Radius', 'sellkit' ),
379 'type' => 'dimensions',
380 'size_units' => [ 'px', '%', 'em' ],
381 'default' => [
382 'unit' => 'px',
383 ],
384 'selectors' => [
385 '{{WRAPPER}} .sellkit-accept-reject-button-widget .sellkit-accept-reject-button' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
386 ],
387 ]
388 );
389
390 $this->add_group_control(
391 'box-shadow',
392 [
393 'name' => 'box_shadow',
394 'selector' => '{{WRAPPER}} .sellkit-accept-reject-button-widget .sellkit-accept-reject-button',
395 ]
396 );
397
398 $this->add_control(
399 'padding_separator',
400 [
401 'type' => 'divider',
402 ]
403 );
404
405 $this->add_responsive_control(
406 'personalised_coupons_padding',
407 [
408 'label' => __( 'Padding', 'sellkit' ),
409 'type' => 'dimensions',
410 'size_units' => [ 'px', 'em', '%' ],
411 'selectors' => [
412 '{{WRAPPER}} .sellkit-accept-reject-button-widget .sellkit-accept-reject-button' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
413 ],
414 ]
415 );
416
417 $this->end_controls_section();
418 }
419
420 protected function render() {
421 $order_key = sellkit_htmlspecialchars( INPUT_GET, 'order-key' );
422 $settings = $this->get_settings_for_display();
423 $button_type_class = ( 'accept' === $settings['offer_type'] ) ? 'sellkit-upsell-accept-button' : 'sellkit-upsell-reject-button';
424 ?>
425 <div class="sellkit-accept-reject-button-widget">
426 <a
427 class="elementor-button sellkit-accept-reject-button <?php echo $button_type_class; ?> elementor-size-<?php echo $settings['button_size']; ?>"
428 data-order-key="<?php echo esc_attr( $order_key ); ?>"
429 >
430 <?php Icons_Manager::render_icon( $settings['selected_icon'] ); ?>
431 <span class="sellkit-accept-reject-button-title" ><?php echo $settings['title']; ?></span>
432 <br>
433 <span class="sellkit-accept-reject-button-sub-title"><?php echo $settings['sub_title']; ?></span>
434 </a>
435 <div class="sellkit-upsell-popup">
436 <div class="sellkit-upsell-popup-body">
437 <div class="sellkit-upsell-popup-header">
438 <img src="<?php echo sellkit()->plugin_url() . 'assets/img/icons/close-cross.svg'; ?>" >
439 </div>
440 <div class="sellkit-upsell-popup-content">
441 <div class="sellkit-upsell-popup-icon">
442 <img class="rotate sellkit-upsell-updating active" src="<?php echo sellkit()->plugin_url() . 'assets/img/icons/sync-alt.svg'; ?>" >
443 <img class="sellkit-upsell-accepted" src="<?php echo sellkit()->plugin_url() . 'assets/img/icons/check-circle.svg'; ?>" >
444 <img class="sellkit-upsell-rejected" src="<?php echo sellkit()->plugin_url() . 'assets/img/icons/times-circle.svg'; ?>" >
445 </div>
446 <div class="sellkit-upsell-popup-text">
447 <div class="sellkit-upsell-updating active">
448 <?php esc_html_e( 'Updating your order…', 'sellkit' ); ?>
449 </div>
450 <div class="sellkit-upsell-accepted">
451 <?php esc_html_e( 'Congratulations! Your item has been successfully added to the order.', 'sellkit' ); ?>
452 </div>
453 <div class="sellkit-upsell-rejected">
454 <?php esc_html_e( 'Sorry! We were unable to add this item to your order.', 'sellkit' ); ?>
455 </div>
456 </div>
457 </div>
458 </div>
459 </div>
460 </div>
461 <?php
462 }
463 }
464