PluginProbe ʕ •ᴥ•ʔ
ShopEngine Elementor WooCommerce Builder Addon – All in One WooCommerce Solution / 4.9.2
ShopEngine Elementor WooCommerce Builder Addon – All in One WooCommerce Solution v4.9.2
4.9.2 4.9.1 4.9.0 2.0.0 2.1.0 2.2.0 2.2.1 2.2.2 2.3.0 2.4.0 2.5.0 2.5.1 3.0.0 3.1.0 3.1.1 4.0.0 4.0.1 4.1.0 4.1.1 4.2.0 4.2.1 4.3.0 4.3.1 4.4.0 4.5.0 4.5.1 4.6.0 4.6.1 4.6.2 4.6.3 4.6.4 4.6.5 4.6.6 4.6.7 4.6.8 4.6.9 4.7.0 4.7.1 4.7.2 4.7.3 4.7.4 4.7.5 4.7.6 4.7.7 4.7.8 4.7.9 4.8.0 4.8.1 4.8.2 4.8.3 4.8.4 4.8.5 4.8.6 4.8.7 4.8.8 4.8.9 trunk 0.1.2-beta 0.1.3-beta 0.1.4-beta 1.0.0 1.1.0 1.1.1 1.1.2 1.1.3 1.2.0 1.2.1 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.4.0 1.4.1 1.5.0 1.5.1 1.6.0 1.6.1 1.7.0 1.8.0 1.8.1 1.9.0
shopengine / widgets / product-image / product-image.php
shopengine / widgets / product-image Last commit date
screens 2 years ago product-image-config.php 4 years ago product-image.php 1 year ago
product-image.php
933 lines
1 <?php
2
3 namespace Elementor;
4
5 use ShopEngine\Widgets\Products;
6
7 defined('ABSPATH') || exit;
8
9 class ShopEngine_Product_Image extends \ShopEngine\Base\Widget {
10
11 public function config() {
12 return new ShopEngine_Product_Image_Config();
13 }
14
15 public function get_script_depends() {
16 return ['wc-single-product'];
17 }
18
19 protected function register_controls() {
20
21 /*
22 --------------------------
23 settings content tab
24 --------------------------
25 */
26
27 $this->start_controls_section(
28 'shopengine_widget_settings',
29 [
30 'label' => esc_html__('Settings', 'shopengine'),
31 'tab' => Controls_Manager::TAB_CONTENT,
32 ]
33 );
34
35 $this->add_control(
36 'shopengine_image_gallery_heading',
37 [
38 'label' => esc_html__('Product Gallery', 'shopengine'),
39 'type' => Controls_Manager::HEADING,
40 'separator' => 'before',
41 ]
42 );
43
44
45 if(\ShopEngine::package_type() == 'free'){
46 $this->add_control(
47 'shopengine_image_gallery_info',
48 [
49 'type' => Controls_Manager::RAW_HTML,
50 'raw' => esc_html__('In the ShopEngine pro version, the thumbnail gallery will be slider automatically and you can move it to the left and right side of the feature image too.', 'shopengine'),
51 'content_classes' => 'elementor-panel-alert elementor-panel-alert-danger',
52 ]
53 );
54 }
55
56 $position_opts = [
57 'bottom' => __( 'Bottom', 'shopengine' )
58 ];
59
60 if(\ShopEngine::package_type() == 'pro'){
61 $position_opts['left'] = __( 'Left', 'shopengine' );
62 $position_opts['right'] = __( 'Right', 'shopengine' );
63 }
64
65 $this->add_control(
66 'shopengine_image_gallery_position',
67 [
68 'label' => __( 'Position', 'shopengine' ),
69 'type' => Controls_Manager::SELECT,
70 'default' => 'bottom',
71 'options' => $position_opts,
72 'prefix_class' => 'shopengine_image_gallery_position_',
73 ]
74 );
75
76 $this->add_control(
77 'shopengine_image_lightbox_icon_heading',
78 [
79 'label' => esc_html__('Product Lightbox', 'shopengine'),
80 'type' => Controls_Manager::HEADING,
81 'separator' => 'before',
82 ]
83 );
84
85 $this->add_control(
86 'shopengine_image_lightbox_icon',
87 [
88 'label' => esc_html__('Icon', 'shopengine'),
89 'type' => Controls_Manager::ICONS,
90 'fa4compatibility' => 'icon',
91 'default' => [
92 'value' => 'fas fa-expand-alt',
93 'library' => 'fa-solid',
94 ],
95 ]
96 );
97
98 $this->add_control(
99 'shopengine_sale_flash_status_heading',
100 [
101 'label' => esc_html__('Flash Sale Badge', 'shopengine'),
102 'type' => Controls_Manager::HEADING,
103 'separator' => 'before',
104 ]
105 );
106
107 $this->add_control(
108 'shopengine_sale_flash_status',
109 [
110 'label' => esc_html__('Show Badge?', 'shopengine'),
111 'type' => Controls_Manager::SWITCHER,
112 'label_on' => esc_html__('Show', 'shopengine'),
113 'label_off' => esc_html__('Hide', 'shopengine'),
114 'render_type' => 'template',
115 'return_value' => 'yes',
116 'default' => 'yes',
117 ]
118 );
119
120 $this->end_controls_section(); // end ./settings content tab
121
122 /*
123 --------------------------
124 product image style
125 --------------------------
126 */
127
128 $this->start_controls_section(
129 'shopengine_image_style',
130 [
131 'label' => esc_html__('Image', 'shopengine'),
132 'tab' => Controls_Manager::TAB_STYLE,
133 ]
134 );
135
136 $this->add_control(
137 'shopengine_image_bgc',
138 [
139 'label' => esc_html__( 'Background Color', 'shopengine' ),
140 'type' => Controls_Manager::COLOR,
141 'selectors' => [
142 '{{WRAPPER}} .woocommerce-product-gallery__image a, .pswp__img ' => 'background-color: {{VALUE}};',
143 ],
144 ]
145 );
146
147 $this->add_control(
148 'shopengine_image_border_radius',
149 [
150 'label' => esc_html__('Border Radius', 'shopengine'),
151 'type' => Controls_Manager::SLIDER,
152 'size_units' => ['px', '%'],
153 'range' => [
154 'px' => [
155 'min' => 0,
156 'max' => 100,
157 'step' => 1,
158 ],
159 '%' => [
160 'min' => 0,
161 'max' => 100,
162 'step' => 1,
163 ],
164 ],
165 'selectors' => [
166 '{{WRAPPER}} .shopengine-product-image .woocommerce-product-gallery__image img' => 'border-radius: {{SIZE}}{{UNIT}};',
167 ],
168 ]
169 );
170
171 $this->add_control(
172 'shopengine_heading_gallery_thumbs_style',
173 [
174 'label' => esc_html__('Gallery Thumbnails', 'shopengine'),
175 'type' => Controls_Manager::HEADING,
176 'separator' => 'before',
177 ]
178 );
179
180 $this->add_responsive_control(
181 'shopengine_gallery_thumbs_width',
182 [
183 'label' => esc_html__('Width', 'shopengine'),
184 'type' => Controls_Manager::SLIDER,
185 'size_units' => ['px', '%'],
186 'range' => [
187 'px' => [
188 'min' => 0,
189 'max' => 1000,
190 'step' => 5,
191 ],
192 '%' => [
193 'min' => 0,
194 'max' => 100,
195 ],
196 ],
197 'devices' => [ 'desktop', 'tablet', 'mobile' ],
198 'desktop_default' => [
199 'size' => 20,
200 'unit' => '%',
201 ],
202 'tablet_default' => [
203 'size' => 25,
204 'unit' => '%',
205 ],
206 'mobile_default' => [
207 'size' => 25,
208 'unit' => '%',
209 ],
210 'default' => [
211 'size' => 20,
212 'unit' => '%',
213 ],
214 'selectors' => [
215 '{{WRAPPER}}:not(.shopengine_image_gallery_position_bottom) .shopengine-gallery-wrapper' => 'width: {{SIZE}}{{UNIT}};',
216 '{{WRAPPER}}.shopengine_image_gallery_position_bottom .flex-control-thumbs li' => 'flex: 0 0 {{SIZE}}{{UNIT}};',
217 '{{WRAPPER}}.shopengine_image_gallery_position_left .flex-viewport, {{WRAPPER}}.shopengine_image_gallery_position_right .flex-viewport' => 'width: calc(100% - {{SIZE}}{{UNIT}});',
218 '{{WRAPPER}}.shopengine_image_gallery_position_left .shopengine-product-image .onsale, {{WRAPPER}}.shopengine_image_gallery_position_left .shopengine-product-image-toggle' => 'margin-left: {{SIZE}}{{UNIT}}',
219 '{{WRAPPER}}.shopengine_image_gallery_position_right .shopengine-product-image .onsale, {{WRAPPER}}.shopengine_image_gallery_position_right .shopengine-product-image-toggle' => 'margin-right: {{SIZE}}{{UNIT}}',
220 ],
221 ]
222 );
223
224 $this->add_group_control(
225 Group_Control_Border::get_type(),
226 [
227 'name' => 'shopengine_thumbs_border',
228 'selector' => '.shopengine-widget .shopengine-product-image .images.woocommerce-product-gallery .flex-control-thumbs li img',
229 'fields_options' => [
230 'color' => [
231 'label' => esc_html__('Border Color', 'shopengine'),
232 'alpha' => false,
233 ],
234
235 ],
236 ]
237 );
238
239 $this->add_control(
240 'shopengine_thumbs_border_radius',
241 [
242 'label' => esc_html__('Border Radius (px)', 'shopengine'),
243 'type' => Controls_Manager::SLIDER,
244 'size_units' => ['px', '%'],
245 'range' => [
246 'px' => [
247 'min' => 0,
248 'max' => 100,
249 'step' => 1,
250 ],
251 '%' => [
252 'min' => 0,
253 'max' => 100,
254 'step' => 1,
255 ],
256 ],
257 'selectors' => [
258 '{{WRAPPER}} .shopengine-widget .shopengine-product-image .images.woocommerce-product-gallery .flex-control-thumbs li img' => 'border-radius: {{SIZE}}{{UNIT}}',
259 ],
260 ]
261 );
262
263 $this->add_control(
264 'shopengine_gallery_thumbs_row_gap',
265 [
266 'label' => esc_html__('Row Gap (px)', 'shopengine'),
267 'type' => Controls_Manager::SLIDER,
268 'size_units' => ['px'],
269 'range' => [
270 'px' => [
271 'min' => 0,
272 'max' => 100,
273 'step' => 1,
274 ],
275 ],
276 'default' => [
277 'unit' => 'px',
278 'size' => 5,
279 ],
280 'selectors' => [
281 '{{WRAPPER}} .shopengine-product-image .flex-control-thumbs li' => 'padding-left: {{SIZE}}{{UNIT}};padding-right: {{SIZE}}{{UNIT}};',
282 '{{WRAPPER}} .shopengine-product-image .flex-control-thumbs' => 'margin-left:-{{SIZE}}{{UNIT}};margin-right: -{{SIZE}}{{UNIT}};',
283 '{{WRAPPER}} .shopengine-product-image .product-thumbs-slider:not( .owl-loaded )' => 'padding-left: {{SIZE}}{{UNIT}};padding-right: {{SIZE}}{{UNIT}};',
284 '{{WRAPPER}} .shopengine-product-image .product-thumbs-slider .owl-stage' => 'padding-left: {{SIZE}}{{UNIT}};padding-right: {{SIZE}}{{UNIT}};',
285 ],
286 ]
287 );
288
289 $column_condition = [];
290
291 if(\ShopEngine::package_type() == 'pro'){
292 $column_condition = [
293 'shopengine_image_gallery_position!' => 'bottom'
294 ];
295 }
296
297 $this->add_control(
298 'shopengine_gallery_thumbs_column_gap',
299 [
300 'label' => esc_html__('Column Gap (px)', 'shopengine'),
301 'type' => Controls_Manager::SLIDER,
302 'size_units' => ['px'],
303 'range' => [
304 'px' => [
305 'min' => 0,
306 'max' => 100,
307 'step' => 1,
308 ],
309 ],
310 'default' => [
311 'unit' => 'px',
312 'size' => 5,
313 ],
314 'selectors' => [
315 '{{WRAPPER}} .shopengine-product-image .flex-control-thumbs li' => 'padding-top: {{SIZE}}{{UNIT}};padding-bottom: {{SIZE}}{{UNIT}};',
316 '{{WRAPPER}} .shopengine-product-image .flex-control-thumbs' => 'margin-top:-{{SIZE}}{{UNIT}};margin-bottom: -{{SIZE}}{{UNIT}};',
317 '{{WRAPPER}} .shopengine-product-image .product-thumbs-slider:not( .owl-loaded )' => 'padding-top: {{SIZE}}{{UNIT}};padding-bottom: {{SIZE}}{{UNIT}};;',
318 '{{WRAPPER}} .shopengine-product-image .product-thumbs-slider .owl-stage' => 'padding-top: {{SIZE}}{{UNIT}};padding-bottom: {{SIZE}}{{UNIT}};;',
319 ],
320 'condition' => $column_condition
321 ]
322 );
323
324 $this->add_responsive_control(
325 'shopengine_thumbs_margin',
326 [
327 'label' => esc_html__('Margin Top (px)', 'shopengine'),
328 'type' => Controls_Manager::SLIDER,
329 'default' => [
330 'size' => '5',
331 ],
332 'size_units' => ['px'],
333 'selectors' => [
334 '{{WRAPPER}} .shopengine-product-image .flex-control-thumbs' => 'margin-top: {{SIZE}}px;',
335 '{{WRAPPER}} .shopengine-product-image .product-thumbs-slider' => 'margin-top: {{SIZE}}px;',
336 ],
337 'separator' => 'before',
338 'condition' => [
339 'shopengine_image_gallery_position' => 'bottom',
340 ]
341 ]
342 );
343
344 $this->end_controls_section(); // end ./ product image style
345
346 /*
347 --------------------------
348 lightbox zoom icon
349 --------------------------
350 */
351
352 $this->start_controls_section(
353 'shopengine_lightbox_icon_style',
354 [
355 'label' => esc_html__('Lightbox Zoom Icon', 'shopengine'),
356 'tab' => Controls_Manager::TAB_STYLE,
357 ]
358 );
359
360 $this->add_control(
361 'shopengine_lightbox_icon_color',
362 [
363 'label' => esc_html__('Icon Color', 'shopengine'),
364 'type' => Controls_Manager::COLOR,
365 'default' => '#101010',
366 'alpha' => false,
367 'selectors' => [
368 '{{WRAPPER}} .shopengine-product-image .shopengine-product-image-toggle' => 'color: {{VALUE}}',
369 ],
370 ]
371 );
372
373 $this->add_control(
374 'shopengine_lightbox_icon_border_color',
375 [
376 'label' => esc_html__('Icon Border Color', 'shopengine'),
377 'type' => Controls_Manager::COLOR,
378 'default' => '#101010',
379 'alpha' => false,
380 'selectors' => [
381 '{{WRAPPER}} .shopengine-product-image .shopengine-product-image-toggle' => 'border:1px solid {{VALUE}}; box-shadow:none;-webkit-box-shadow:none;',
382 ],
383 ]
384 );
385
386 $this->add_control(
387 'shopengine_lightbox_icon_background',
388 [
389 'label' => esc_html__('Icon Background Color', 'shopengine'),
390 'type' => Controls_Manager::COLOR,
391 'alpha' => false,
392 'default' => '#ffffff',
393 'selectors' => [
394 '{{WRAPPER}} .shopengine-product-image .shopengine-product-image-toggle' => 'background-color: {{VALUE}}',
395 ],
396 ]
397 );
398
399 $this->add_control(
400 'shopengine_lightbox_icon_size',
401 [
402 'label' => esc_html__('Size (px)', 'shopengine'),
403 'type' => Controls_Manager::SLIDER,
404 'size_units' => ['px'],
405 'range' => [
406 'px' => [
407 'min' => 0,
408 'max' => 100,
409 'step' => 1,
410 ],
411 ],
412 'default' => [
413 'unit' => 'px',
414 'size' => 18,
415 ],
416 'selectors' => [
417 '{{WRAPPER}} .shopengine-product-image .shopengine-product-image-toggle' => 'font-size: {{SIZE}}{{UNIT}};',
418 '{{WRAPPER}} .shopengine-product-image .shopengine-product-image-toggle svg' => 'width: {{SIZE}}{{UNIT}};',
419 ],
420 ]
421 );
422
423 $this->add_control(
424 'shopengine_lightbox_icon_wrapper_height',
425 [
426 'label' => esc_html__('Wrapper height (px)', 'shopengine'),
427 'type' => Controls_Manager::SLIDER,
428 'size_units' => ['px'],
429 'range' => [
430 'px' => [
431 'min' => 0,
432 'max' => 100,
433 'step' => 1,
434 ],
435 ],
436 'default' => [
437 'unit' => 'px',
438 'size' => 40,
439 ],
440 'selectors' => [
441 '{{WRAPPER}} .shopengine-product-image .shopengine-product-image-toggle' => 'height: {{SIZE}}{{UNIT}};',
442 ],
443 ]
444 );
445
446 $this->add_control(
447 'shopengine_lightbox_icon_wrapper_width',
448 [
449 'label' => esc_html__('Wrapper width (px)', 'shopengine'),
450 'type' => Controls_Manager::SLIDER,
451 'size_units' => ['px'],
452 'range' => [
453 'px' => [
454 'min' => 0,
455 'max' => 100,
456 'step' => 1,
457 ],
458 ],
459 'default' => [
460 'unit' => 'px',
461 'size' => 80,
462 ],
463 'selectors' => [
464 '{{WRAPPER}} .shopengine-product-image .shopengine-product-image-toggle' => 'width: {{SIZE}}{{UNIT}}',
465 ],
466 ]
467 );
468
469 $this->add_control(
470 'shopengine_lightbox_icon_radius',
471 [
472 'label' => esc_html__('Border Radius (px)', 'shopengine'),
473 'type' => Controls_Manager::SLIDER,
474 'size_units' => ['px'],
475 'range' => [
476 'px' => [
477 'min' => 0,
478 'max' => 100,
479 'step' => 5,
480 ],
481 ],
482 'default' => [
483 'unit' => 'px',
484 'size' => 100,
485 ],
486 'selectors' => [
487 '{{WRAPPER}} .shopengine-product-image .shopengine-product-image-toggle' => 'border-radius: {{SIZE}}{{UNIT}}',
488 ],
489 ]
490 );
491
492 $this->add_control(
493 'shopengine_lightbox_icon_position',
494 [
495 'label' => esc_html__('Position', 'shopengine'),
496 'type' => Controls_Manager::CHOOSE,
497 'options' => [
498 'top-left' => [
499 'title' => esc_html__('Top Left', 'shopengine'),
500 'icon' => 'eicon-h-align-left',
501 ],
502 'top-right' => [
503 'title' => esc_html__('Top Right', 'shopengine'),
504 'icon' => 'eicon-h-align-right',
505 ],
506 'custom' => [
507 'title' => esc_html__('Custom', 'shopengine'),
508 'icon' => 'eicon-settings',
509 ],
510 ],
511 'default' => 'top-right',
512 'toggle' => false,
513 'separator' => 'before',
514 ]
515 );
516
517 $this->add_control(
518 'shopengine_lightbox_icon_position_x_axis',
519 [
520 'label' => esc_html__('Badge Position (X axis)', 'shopengine'),
521 'type' => Controls_Manager::SLIDER,
522 'size_units' => ['px', '%'],
523 'range' => [
524 'px' => [
525 'min' => 0,
526 'max' => 1000,
527 'step' => 1,
528 ],
529 '%' => [
530 'min' => 0,
531 'max' => 100,
532 ],
533 ],
534 'default' => [
535 'unit' => 'px',
536 'size' => 20,
537 ],
538 'selectors' => [
539 '{{WRAPPER}} .shopengine-product-image .shopengine-product-image-toggle' => 'left: {{SIZE}}{{UNIT}};',
540 ],
541 'condition' => [
542 'shopengine_lightbox_icon_position' => 'custom',
543 ],
544 ]
545 );
546
547 $this->add_control(
548 'shopengine_lightbox_icon_position_y_axis',
549 [
550 'label' => esc_html__('Badge Position (Y axis)', 'shopengine'),
551 'type' => Controls_Manager::SLIDER,
552 'size_units' => ['px', '%'],
553 'range' => [
554 'px' => [
555 'min' => 0,
556 'max' => 1000,
557 'step' => 1,
558 ],
559 '%' => [
560 'min' => 0,
561 'max' => 100,
562 ],
563 ],
564 'default' => [
565 'unit' => 'px',
566 'size' => 20,
567 ],
568 'selectors' => [
569 '{{WRAPPER}} .shopengine-product-image .shopengine-product-image-toggle' => 'top: {{SIZE}}{{UNIT}};',
570 ],
571 'condition' => [
572 'shopengine_lightbox_icon_position' => 'custom',
573 ],
574 ]
575 );
576
577 $this->end_controls_section(); // end ./ lightbox zoom icon
578
579 /*
580 --------------------------
581 Flash sale badge style
582 --------------------------
583 */
584 $this->start_controls_section(
585 'shopengine_flash_sale_badge_style',
586 [
587 'label' => esc_html__('Flash Sale Badge', 'shopengine'),
588 'tab' => Controls_Manager::TAB_STYLE,
589 'condition' => [
590 'shopengine_sale_flash_status' => 'yes',
591 ],
592 ]
593 );
594
595 $this->add_control(
596 'shopengine_flash_sale_color',
597 [
598 'label' => esc_html__('Color', 'shopengine'),
599 'type' => Controls_Manager::COLOR,
600 'default' => '#ffffff',
601 'alpha' => false,
602 'selectors' => [
603 '{{WRAPPER}} .shopengine-product-image .onsale' => 'color: {{VALUE}}',
604 ],
605 ]
606 );
607
608 $this->add_control(
609 'shopengine_flash_sale_background',
610 [
611 'label' => esc_html__('Background Color', 'shopengine'),
612 'type' => Controls_Manager::COLOR,
613 'default' => '#8fa775',
614 'alpha' => false,
615 'selectors' => [
616 '{{WRAPPER}} .shopengine-product-image .onsale' => 'background-color: {{VALUE}}',
617 ],
618 ]
619 );
620
621 $this->add_group_control(
622 Group_Control_Typography::get_type(),
623 [
624 'name' => 'shopengine_onsale_primary',
625 'label' => esc_html__('Typography', 'shopengine'),
626 'selector' => '{{WRAPPER}} .shopengine-product-image .onsale',
627 'exclude' => ['letter_spacing', 'text_decoration', 'font_weight', 'font_style'],
628
629 'fields_options' => [
630 'typography' => [
631 'default' => 'custom',
632 ],
633 'font_size' => [
634 'label' => esc_html__('Font Size (px)', 'shopengine'),
635 'default' => [
636 'size' => '16',
637 'unit' => 'px',
638 ],
639 'size_units' => ['px'],
640 ],
641 'line_height' => [
642 'label' => esc_html__('Line-height (px)', 'shopengine'),
643 'default' => [
644 'size' => '20',
645 'unit' => 'px',
646 ],
647 'size_units' => ['px'],
648 ],
649 ],
650 ]
651 );
652
653 $this->add_control(
654 'shopengine_flash_sale_height_width_status',
655 [
656 'label' => esc_html__('Fixed Height Width', 'shopengine'),
657 'type' => Controls_Manager::SWITCHER,
658 'label_on' => esc_html__('Show', 'shopengine'),
659 'label_off' => esc_html__('Hide', 'shopengine'),
660 'render_type' => 'template',
661 'return_value' => 'yes',
662 'default' => 'yes',
663 ]
664 );
665
666 $this->add_control(
667 'shopengine_flash_sale_height',
668 [
669 'label' => esc_html__('Height (px)', 'shopengine'),
670 'type' => Controls_Manager::SLIDER,
671 'size_units' => ['px'],
672 'range' => [
673 'px' => [
674 'min' => 0,
675 'max' => 200,
676 'step' => 1,
677 ],
678 ],
679 'default' => [
680 'unit' => 'px',
681 'size' => 70,
682 ],
683 'selectors' => [
684 '{{WRAPPER}} .shopengine-product-image .onsale' => 'height: {{SIZE}}{{UNIT}};',
685 ],
686 'condition' => [
687 'shopengine_flash_sale_height_width_status' => 'yes',
688 ],
689 ]
690 );
691
692 $this->add_control(
693 'shopengine_flash_sale_width',
694 [
695 'label' => esc_html__('Width (px)', 'shopengine'),
696 'type' => Controls_Manager::SLIDER,
697 'size_units' => ['px'],
698 'range' => [
699 'px' => [
700 'min' => 0,
701 'max' => 200,
702 'step' => 1,
703 ],
704 ],
705 'default' => [
706 'unit' => 'px',
707 'size' => 70,
708 ],
709 'selectors' => [
710 '{{WRAPPER}} .shopengine-product-image .onsale' => 'width: {{SIZE}}{{UNIT}}',
711 ],
712 'condition' => [
713 'shopengine_flash_sale_height_width_status' => 'yes',
714 ],
715 ]
716 );
717
718 $this->add_control(
719 'shopengine_flash_sale_radius',
720 [
721 'label' => esc_html__('Border Radius (px)', 'shopengine'),
722 'type' => Controls_Manager::SLIDER,
723 'size_units' => ['px'],
724 'range' => [
725 'px' => [
726 'min' => 0,
727 'max' => 100,
728 'step' => 1,
729 ],
730 ],
731 'default' => [
732 'unit' => 'px',
733 'size' => 70,
734 ],
735 'selectors' => [
736 '{{WRAPPER}} .shopengine-product-image .onsale' => 'border-radius: {{SIZE}}{{UNIT}}',
737 ],
738 ]
739 );
740
741 $this->add_control(
742 'shopengine_flash_sale_position',
743 [
744 'label' => esc_html__('Position', 'shopengine'),
745 'type' => Controls_Manager::CHOOSE,
746 'options' => [
747 'top-left' => [
748 'title' => esc_html__('Top Left', 'shopengine'),
749 'icon' => 'eicon-h-align-left',
750 ],
751 'top-right' => [
752 'title' => esc_html__('Top Right', 'shopengine'),
753 'icon' => 'eicon-h-align-right',
754 ],
755 'custom' => [
756 'title' => esc_html__('Custom', 'shopengine'),
757 'icon' => 'eicon-settings',
758 ],
759 ],
760 'default' => 'top-left',
761 'toggle' => false,
762 'separator' => 'before',
763 ]
764 );
765
766 $this->add_control(
767 'shopengine_flash_sale_position_x_axis',
768 [
769 'label' => esc_html__('Badge Position (X axis)', 'shopengine'),
770 'type' => Controls_Manager::SLIDER,
771 'size_units' => ['px', '%'],
772 'range' => [
773 'px' => [
774 'min' => 0,
775 'max' => 1000,
776 'step' => 1,
777 ],
778 '%' => [
779 'min' => 0,
780 'max' => 100,
781 ],
782 ],
783 'default' => [
784 'unit' => 'px',
785 'size' => 20,
786 ],
787 'selectors' => [
788 '{{WRAPPER}} .shopengine-product-image .onsale' => 'left: {{SIZE}}{{UNIT}};',
789 ],
790 'condition' => [
791 'shopengine_flash_sale_position' => 'custom',
792 ],
793 ]
794 );
795
796 $this->add_control(
797 'shopengine_flash_sale_position_y_axis',
798 [
799 'label' => esc_html__('Badge Position (Y axis)', 'shopengine'),
800 'type' => Controls_Manager::SLIDER,
801 'size_units' => ['px', '%'],
802 'range' => [
803 'px' => [
804 'min' => 0,
805 'max' => 1000,
806 'step' => 1,
807 ],
808 '%' => [
809 'min' => 0,
810 'max' => 100,
811 ],
812 ],
813 'default' => [
814 'unit' => 'px',
815 'size' => 20,
816 ],
817 'selectors' => [
818 '{{WRAPPER}} .shopengine-product-image .onsale' => 'top: {{SIZE}}{{UNIT}};',
819 ],
820 'condition' => [
821 'shopengine_flash_sale_position' => 'custom',
822 ],
823 ]
824 );
825
826 $this->end_controls_section();
827
828 /*
829 --------------------------
830 Slider Nav style
831 --------------------------
832 */
833 $this->start_controls_section(
834 'shopengine_gallery_nav_style',
835 [
836 'label' => esc_html__('Slider Nav', 'shopengine'),
837 'tab' => Controls_Manager::TAB_STYLE,
838 ]
839 );
840
841 $this->add_control(
842 'shopengine_slider_icon_size',
843 [
844 'label' => esc_html__('Size (px)', 'shopengine'),
845 'type' => Controls_Manager::SLIDER,
846 'size_units' => ['px'],
847 'range' => [
848 'px' => [
849 'min' => 0,
850 'max' => 100,
851 'step' => 1,
852 ],
853 ],
854 'default' => [
855 'unit' => 'px',
856 'size' => 16,
857 ],
858 'selectors' => [
859 '{{WRAPPER}} .shopengine-product-image .flex-direction-nav .flex-prev:before, .shopengine-widget .shopengine-product-image .flex-direction-nav .flex-next:before' => 'font-size: {{SIZE}}{{UNIT}};',
860 ],
861 ]
862 );
863
864 $this->add_control(
865 'shopengine_slider_nav_icon_color',
866 [
867 'label' => esc_html__('Icon Color', 'shopengine'),
868 'type' => Controls_Manager::COLOR,
869 'default' => '#101010',
870 'alpha' => false,
871 'selectors' => [
872 '{{WRAPPER}} .shopengine-product-image .flex-direction-nav .flex-prev:before, .shopengine-widget .shopengine-product-image .flex-direction-nav .flex-next:before' => 'color: {{VALUE}}',
873 ],
874 ]
875 );
876
877 $this->add_control(
878 'shopengine_slider_nav_background',
879 [
880 'label' => esc_html__('Background Color', 'shopengine'),
881 'type' => Controls_Manager::COLOR,
882 'default' => '#fff',
883 'alpha' => false,
884 'selectors' => [
885 '{{WRAPPER}} .shopengine-product-image .flex-direction-nav .flex-prev:before, .shopengine-widget .shopengine-product-image .flex-direction-nav .flex-next:before' => 'background-color: {{VALUE}}',
886 ],
887 ]
888 );
889
890 $this->end_controls_section();
891 }
892
893 /**
894 * Render widget output on the frontend.
895 *
896 * Written in PHP and used to generate the final HTML.
897 *
898 * @since 1.0.0
899 * @access protected
900 */
901 protected function screen() {
902 $settings = $this->get_settings_for_display();
903 ?>
904
905 <div class="shopengine-product-image <?php echo \ShopEngine::package_type() == 'pro' ? 'shopengine-gallery-slider' : 'shopengine-gallery-slider-no' ?>">
906 <button title="<?php esc_html_e('Product Thumbnail','shopengine')?>"
907 class="shopengine-product-image-toggle position-<?php echo esc_attr($settings['shopengine_lightbox_icon_position']); ?>">
908 <?php Icons_Manager::render_icon($settings['shopengine_image_lightbox_icon'], ['aria-hidden' => 'true']); ?>
909 </button>
910 <?php shopengine_content_render(\ShopEngine\Utils\Helper::render($this->view_render($settings)));?>
911 </div>
912
913 <?php
914 }
915
916
917 protected function view_render($settings = []) {
918
919 /*
920 TODO: As we are redirecting the users from shopengine\core\builders\hooks.php file if there is no product found with the given ID. So we need to remove the sample products attachment below. Because it is unused.
921 */
922
923 $product = wc_get_product();
924 if(empty($product)) {
925 $product = Products::instance()->get_product('');
926 }
927
928 $tpl = Products::instance()->get_widget_template('shopengine-product-image');
929
930 include $tpl;
931 }
932 }
933