PluginProbe ʕ •ᴥ•ʔ
ShopEngine Elementor WooCommerce Builder Addon – All in One WooCommerce Solution / 4.6.5
ShopEngine Elementor WooCommerce Builder Addon – All in One WooCommerce Solution v4.6.5
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 / related / related.php
shopengine / widgets / related Last commit date
screens 2 years ago related-config.php 4 years ago related.php 2 years ago
related.php
1743 lines
1 <?php
2
3 namespace Elementor;
4
5 defined('ABSPATH') || exit;
6
7
8 use ShopEngine\Widgets\Products;
9
10 class ShopEngine_Related extends \ShopEngine\Base\Widget
11 {
12
13 public function config() {
14 return new ShopEngine_Related_Config();
15 }
16
17 protected function register_controls() {
18
19 /*
20 * Content Tab
21 */
22 $this->start_controls_section(
23 'shopengine_related_product_content_section',
24 [
25 'label' => esc_html__('Content', 'shopengine'),
26 'tab' => Controls_Manager::TAB_CONTENT,
27 ]
28 );
29
30 $this->add_control(
31 'shopengine_related_product_enable_slider',
32 [
33 'label' => esc_html__('Enable Slider', 'shopengine'),
34 'type' => Controls_Manager::SWITCHER,
35 'label_on' => esc_html__('Yes', 'shopengine'),
36 'label_off' => esc_html__('No', 'shopengine'),
37 'return_value' => 'yes',
38 'default' => 'yes',
39 'separator' => 'before',
40 ]
41 );
42
43 $this->add_control(
44 'shopengine_related_product_show_flash_sale',
45 [
46 'label' => esc_html__('Flash Sale', 'shopengine'),
47 'type' => Controls_Manager::SWITCHER,
48 'label_on' => esc_html__('Show', 'shopengine'),
49 'label_off' => esc_html__('Hide', 'shopengine'),
50 'return_value' => 'yes',
51 'default' => 'yes',
52 'selectors' => [
53 '{{WRAPPER}} .shopengine-related .related .onsale' => 'display: block;',
54 ],
55 ]
56 );
57
58 $this->add_control(
59 'shopengine_related_product_show_sale_price',
60 [
61 'label' => esc_html__('Sale Price', 'shopengine'),
62 'type' => Controls_Manager::SWITCHER,
63 'label_on' => esc_html__('Show', 'shopengine'),
64 'label_off' => esc_html__('Hide', 'shopengine'),
65 'return_value' => 'yes',
66 'default' => 'yes',
67 'selectors' => [
68 '{{WRAPPER}} .shopengine-related .related .price del' => 'display: inline-block;',
69 ],
70 ]
71 );
72
73 $this->add_control(
74 'shopengine_related_product_show_cart_btn',
75 [
76 'label' => esc_html__('Cart Button', 'shopengine'),
77 'type' => Controls_Manager::SWITCHER,
78 'label_on' => esc_html__('Show', 'shopengine'),
79 'label_off' => esc_html__('Hide', 'shopengine'),
80 'return_value' => 'yes',
81 'default' => 'yes',
82 'selectors' => [
83 '{{WRAPPER}} .shopengine-related .related .button' => 'display: block;',
84 ],
85 ]
86 );
87
88 $this->add_control(
89 'shopengine_related_product_to_show',
90 [
91 'label' => esc_html__('Products to Show', 'shopengine'),
92 'description' => esc_html__('How many products want show in total.', 'shopengine'),
93 'type' => Controls_Manager::NUMBER,
94 'default' => 4,
95 'min' => 1,
96 'max' => 50,
97 'separator' => 'before',
98 ]
99 );
100
101 $this->add_responsive_control(
102 'shopengine_related_product_columns',
103 [
104 'label' => esc_html__('Columns', 'shopengine'),
105 'description' => esc_html__('How many products want show per row.', 'shopengine'),
106 'type' => Controls_Manager::NUMBER,
107 'default' => 4,
108 'tablet_default' => 2,
109 'mobile_default' => 1,
110 'min' => 1,
111 'max' => 12,
112 'selectors' => [
113 '{{WRAPPER}} .shopengine-related ul.products' => 'display: grid; grid-template-columns: repeat({{SIZE}}, 1fr) !important;',
114 ],
115 'condition' => [
116 'shopengine_related_product_enable_slider!' => 'yes',
117 ],
118 ]
119 );
120
121 $this->end_controls_section();
122
123 /*
124 * Content Tab - Slider Controls
125 */
126 $this->start_controls_section(
127 'shopengine_related_product_slider_controls_section',
128 [
129 'label' => esc_html__('Slider Controls', 'shopengine'),
130 'tab' => Controls_Manager::TAB_CONTENT,
131 'condition' => [
132 'shopengine_related_product_enable_slider' => 'yes',
133 ],
134 ]
135 );
136
137 $this->add_responsive_control(
138 'shopengine_related_product_slider_perview',
139 [
140 'label' => esc_html__('Slides Per View', 'shopengine'),
141 'type' => Controls_Manager::NUMBER,
142 'min' => 1,
143 'default' => 4,
144 'max' => 12,
145 'desktop_default' => 4,
146 'tablet_default' => 2,
147 'mobile_default' => 1,
148 'description' => esc_html__('This value will be the number of slides to show in viewport.', 'shopengine'),
149 ]
150 );
151
152 $this->add_control(
153 'shopengine_related_product_slider_loop',
154 [
155 'label' => esc_html__('Loop', 'shopengine'),
156 'type' => Controls_Manager::SWITCHER,
157 'label_on' => esc_html__('Yes', 'shopengine'),
158 'label_off' => esc_html__('No', 'shopengine'),
159 'default' => 'yes',
160 'return_value' => 'yes',
161 ]
162 );
163
164 $this->add_control(
165 'shopengine_related_product_slider_autoplay',
166 [
167 'label' => esc_html__('Autoplay', 'shopengine'),
168 'type' => Controls_Manager::SWITCHER,
169 'label_on' => esc_html__('Yes', 'shopengine'),
170 'label_off' => esc_html__('No', 'shopengine'),
171 'default' => 'yes',
172 'return_value' => 'yes',
173 ]
174 );
175
176 $this->add_control(
177 'shopengine_related_product_slider_autoplay_delay',
178 [
179 'label' => esc_html__('Slide Speed', 'shopengine'),
180 'type' => Controls_Manager::NUMBER,
181 'default' => 3000,
182 'min' => 0,
183 'max' => 10000,
184 'condition' => [
185 'shopengine_related_product_slider_autoplay' => 'yes',
186 ],
187 ]
188 );
189
190 $this->add_control(
191 'shopengine_related_product_slider_show_arrows',
192 [
193 'label' => esc_html__('Show Arrows', 'shopengine'),
194 'type' => Controls_Manager::SWITCHER,
195 'label_off' => esc_html__('Hide', 'shopengine'),
196 'label_on' => esc_html__('Show', 'shopengine'),
197 'default' => 'yes',
198 'return_value' => 'yes',
199 'condition' => [
200 'shopengine_related_product_slider_loop' => 'yes',
201 ],
202 ]
203 );
204
205 $this->add_control(
206 'shopengine_related_product_slider_show_dots',
207 [
208 'label' => esc_html__('Show Dots', 'shopengine'),
209 'type' => Controls_Manager::SWITCHER,
210 'label_off' => esc_html__('Hide', 'shopengine'),
211 'label_on' => esc_html__('Show', 'shopengine'),
212 'default' => 'yes',
213 'return_value' => 'yes',
214 ]
215 );
216
217
218 $this->add_control(
219 'shopengine_related_product_slider_left_arrow_icon',
220 [
221 'label' => esc_html__('Left Arrow', 'shopengine'),
222 'type' => Controls_Manager::ICONS,
223 'fa4compatibility' => 'icon',
224 'default' => [
225 'value' => 'fas fa-chevron-left',
226 'library' => 'fa-solid',
227 ],
228 'condition' => [
229 'shopengine_related_product_slider_show_arrows' => 'yes',
230 ],
231 ]
232 );
233
234 $this->add_control(
235 'shopengine_related_product_slider_right_arrow_icon',
236 [
237 'label' => esc_html__('Right Arrow', 'shopengine'),
238 'type' => Controls_Manager::ICONS,
239 'fa4compatibility' => 'icon',
240 'default' => [
241 'value' => 'fas fa-chevron-right',
242 'library' => 'fa-solid',
243 ],
244 'condition' => [
245 'shopengine_related_product_slider_show_arrows' => 'yes',
246 ],
247 ]
248 );
249
250 $this->add_control(
251 'shopengine_related_product_slider_dots_size',
252 [
253 'label' => esc_html__('Dots Size (px)', 'shopengine'),
254 'type' => Controls_Manager::SLIDER,
255 'size_units' => ['px'],
256 'range' => [
257 'px' => [
258 'min' => 0,
259 'max' => 50,
260 'step' => 1,
261 ],
262 ],
263 'default' => [
264 'unit' => 'px',
265 'size' => 6,
266 ],
267 'selectors' => [
268 '{{WRAPPER}} .shopengine-related .swiper-pagination-bullet' => 'width: {{SIZE}}{{UNIT}};height: {{SIZE}}{{UNIT}};',
269 ],
270 'condition' => [
271 'shopengine_related_product_slider_show_dots' => 'yes',
272 ],
273 'separator' => 'before',
274 ]
275 );
276
277 $this->add_control(
278 'shopengine_related_product_slider_dots_size_active',
279 [
280 'label' => esc_html__('Active Dots Size (px)', 'shopengine'),
281 'type' => Controls_Manager::SLIDER,
282 'size_units' => ['px'],
283 'range' => [
284 'px' => [
285 'min' => 0,
286 'max' => 50,
287 'step' => 1,
288 ],
289 ],
290 'default' => [
291 'unit' => 'px',
292 'size' => 15,
293 ],
294 'selectors' => [
295 '{{WRAPPER}} .shopengine-related .swiper-pagination-bullet.swiper-pagination-bullet-active' => 'width: {{SIZE}}{{UNIT}};height: {{SIZE}}{{UNIT}};',
296 ],
297 'condition' => [
298 'shopengine_related_product_slider_show_dots' => 'yes',
299 ],
300 ]
301 );
302
303 $this->end_controls_section();
304
305 /*
306 * Content Tab - Advanced Slider Controls
307 */
308 $this->start_controls_section(
309 'shopengine_related_product_advance_controls',
310 [
311 'label' => esc_html__('Advanced', 'shopengine'),
312 'tab' => Controls_Manager::TAB_CONTENT,
313 ]
314 );
315
316 $this->add_control(
317 'shopengine_related_product_orderby',
318 [
319 'label' => esc_html__('Order By', 'shopengine'),
320 'type' => Controls_Manager::SELECT,
321 'default' => 'rand',
322 'options' => [
323 'date' => esc_html__('Date', 'shopengine'),
324 'title' => esc_html__('Title', 'shopengine'),
325 'price' => esc_html__('Price', 'shopengine'),
326 'popularity' => esc_html__('Popularity', 'shopengine'),
327 'rating' => esc_html__('Rating', 'shopengine'),
328 'rand' => esc_html__('Random', 'shopengine'),
329 'menu_order' => esc_html__('Menu Order', 'shopengine'),
330 'modified' => esc_html__('Modified Date', 'shopengine'),
331 ],
332 ]
333 );
334
335 $this->add_control(
336 'shopengine_related_product_order',
337 [
338 'label' => esc_html__('Order', 'shopengine'),
339 'type' => Controls_Manager::SELECT,
340 'default' => 'desc',
341 'options' => [
342 'desc' => esc_html__('DESC', 'shopengine'),
343 'asc' => esc_html__('ASC', 'shopengine'),
344 ],
345 ]
346 );
347
348 $this->end_controls_section();
349
350 /*
351 * Style Tab - Products Wrap
352 */
353 $this->start_controls_section(
354 'shopengine_related_product_items_section',
355 [
356 'label' => esc_html__('Items', 'shopengine'),
357 'tab' => Controls_Manager::TAB_STYLE,
358 ]
359 );
360
361 $this->add_responsive_control(
362 'shopengine_related_product_text_align',
363 [
364 'label' => esc_html__('Text Align', 'shopengine'),
365 'type' => Controls_Manager::CHOOSE,
366 'options' => [
367 'left' => [
368 'title' => esc_html__('Left', 'shopengine'),
369 'icon' => 'eicon-text-align-left',
370 ],
371 'center' => [
372 'title' => esc_html__('Center', 'shopengine'),
373 'icon' => 'eicon-text-align-center',
374 ],
375 'right' => [
376 'title' => esc_html__('Right', 'shopengine'),
377 'icon' => 'eicon-text-align-right',
378 ],
379 ],
380 'default' => 'left',
381 'selectors_dictionary' => [
382 'left' => 'text-align: left; justify-content: flex-start;',
383 'center' => 'text-align: center; justify-content: center;',
384 'right' => 'text-align: right; justify-content: flex-end;',
385 ],
386 'selectors' => [
387 '{{WRAPPER}} .shopengine-related .related :is(.product, .price)' => '{{VALUE}};',
388 '.rtl {{WRAPPER}}.elementor-align-left a.woocommerce-LoopProduct-link' => 'text-align:right;',
389 '.rtl {{WRAPPER}}.elementor-align-right a.woocommerce-LoopProduct-link' => 'text-align:left;',
390 ],
391 'prefix_class' => 'elementor%s-align-',
392 ]
393 );
394
395 $this->add_responsive_control(
396 'shopengine_related_product_column_gap',
397 [
398 'label' => esc_html__('Column Gap (px)', 'shopengine'),
399 'type' => Controls_Manager::SLIDER,
400 'size_units' => ['px'],
401 'range' => [
402 'px' => [
403 'min' => 0,
404 'max' => 100,
405 'step' => 1,
406 ],
407 ],
408 'default' => [
409 'unit' => 'px',
410 'size' => 30,
411 ],
412 'selectors' => [
413 '{{WRAPPER}} .shopengine-related.slider-disabled ul.products' => 'grid-gap: {{SIZE}}{{UNIT}};',
414 ],
415 ]
416 );
417
418 $this->add_control(
419 'shopengine_related_product_buttons',
420 [
421 'label' => esc_html__( 'Buttons', 'shopengine' ),
422 'type' => Controls_Manager::HEADING,
423 'separator' => 'before',
424 ]
425 );
426
427 $this->add_control(
428 'shopengine_related_product_btns_space_between',
429 [
430 'label' => esc_html__('Space In-between
431 (px)', 'shopengine'),
432 'type' => Controls_Manager::SLIDER,
433 'size_units' => ['px'],
434 'range' => [
435 'px' => [
436 'min' => 0,
437 'max' => 50,
438 'step' => 1,
439 ],
440 ],
441 'default' => [
442 'unit' => 'px',
443 'size' => 10,
444 ],
445 'selectors' => [
446 '{{WRAPPER}} .shopengine-related .related .products li a:not(.woocommerce-LoopProduct-link, .add_to_cart_button, .product_type_simple, .product_type_external, .product_type_variable, :last-child)' => 'margin-right: {{SIZE}}{{UNIT}};',
447 ],
448 ]
449 );
450
451 $this->add_control(
452 'shopengine_related_product_btns_icon_size',
453 [
454 'label' => esc_html__('Module Icon Size (px)', 'shopengine'),
455 'type' => Controls_Manager::SLIDER,
456 'size_units' => ['px'],
457 'range' => [
458 'px' => [
459 'min' => 0,
460 'max' => 50,
461 'step' => 1,
462 ],
463 ],
464 'default' => [
465 'unit' => 'px',
466 'size' => 16,
467 ],
468 'selectors' => [
469 '{{WRAPPER}} .shopengine-related .related .products li a:not(.woocommerce-LoopProduct-link, .add_to_cart_button, .product_type_simple, .product_type_external, .product_type_variable)' => 'font-size: {{SIZE}}{{UNIT}};',
470 ],
471 ]
472 );
473
474 $this->end_controls_section();
475
476 /*
477 * Style Tab - Flash Sale
478 */
479 $this->start_controls_section(
480 'shopengine_related_product_flash_sale',
481 [
482 'label' => esc_html__('Flash Sale', 'shopengine'),
483 'tab' => Controls_Manager::TAB_STYLE,
484 'condition' => [
485 'shopengine_related_product_show_flash_sale' => 'yes',
486 ],
487 ]
488 );
489
490 $this->add_control(
491 'shopengine_related_product_flash_sale_color',
492 [
493 'label' => esc_html__('Color', 'shopengine'),
494 'type' => Controls_Manager::COLOR,
495 'default' => '#FFFFFF',
496 'alpha' => false,
497 'selectors' => [
498 '{{WRAPPER}} .shopengine-related .onsale' => 'color: {{VALUE}};',
499 ],
500 ]
501 );
502
503 $this->add_control(
504 'shopengine_related_product_flash_sale_bg_color',
505 [
506 'label' => esc_html__('Background Color', 'shopengine'),
507 'type' => Controls_Manager::COLOR,
508 'default' => '#4285f4',
509 'alpha' => false,
510 'selectors' => [
511 '{{WRAPPER}} .shopengine-related .onsale' => 'background-color: {{VALUE}};',
512 ],
513 ]
514 );
515
516 $this->add_group_control(
517 Group_Control_Typography::get_type(),
518 [
519 'name' => 'shopengine_related_product_flash_sale_badge_typography',
520 'label' => esc_html__('Typography', 'shopengine'),
521 'selector' => '{{WRAPPER}} .shopengine-related .onsale',
522 'exclude' => ['font_family', 'letter_spacing', 'text_decoration', 'font_style'],
523 'fields_options' => [
524 'typography' => [
525 'default' => 'custom',
526 ],
527 'font_weight' => [
528 'default' => '400',
529 ],
530 'font_size' => [
531 'label' => esc_html__('Font Size (px)', 'shopengine'),
532 'default' => [
533 'size' => '12',
534 'unit' => 'px',
535 ],
536 'size_units' => ['px'],
537 ],
538 'text_transform' => [
539 'default' => '',
540 ],
541 'line_height' => [
542 'label' => esc_html__('Line Height (px)', 'shopengine'),
543 'default' => [
544 'size' => '44',
545 'unit' => 'px',
546 ],
547 'size_units' => ['px'],
548 'tablet_default' => [
549 'unit' => 'px',
550 ],
551 'mobile_default' => [
552 'unit' => 'px',
553 ],
554 ],
555 ],
556 ]
557 );
558
559 $this->add_responsive_control(
560 'shopengine_related_product_flash_sale_badge_size',
561 [
562 'label' => esc_html__('Badge Size (px)', 'shopengine'),
563 'type' => Controls_Manager::SLIDER,
564 'size_units' => ['px'],
565 'range' => [
566 'px' => [
567 'min' => 0,
568 'max' => 100,
569 'step' => 1,
570 ],
571 ],
572 'default' => [
573 'unit' => 'px',
574 'size' => 44,
575 ],
576 'selectors' => [
577 '{{WRAPPER}} .shopengine-related .onsale' => 'width: {{SIZE}}{{UNIT}}; height: {{SIZE}}{{UNIT}}; line-height: {{SIZE}}{{UNIT}};',
578 ],
579 'separator' => 'before',
580 ]
581 );
582
583 $this->add_responsive_control(
584 'shopengine_related_product_flash_sale_badge_border_radius',
585 [
586 'label' => esc_html__('Badge Border Radius (px)', 'shopengine'),
587 'type' => Controls_Manager::SLIDER,
588 'size_units' => ['px'],
589 'range' => [
590 'px' => [
591 'min' => 0,
592 'max' => 100,
593 'step' => 1,
594 ],
595 ],
596 'default' => [
597 'unit' => 'px',
598 'size' => 100,
599 ],
600 'selectors' => [
601 '{{WRAPPER}} .shopengine-related .onsale' => 'border-radius: {{SIZE}}{{UNIT}};',
602 ],
603 ]
604 );
605
606 $this->add_responsive_control(
607 'shopengine_related_product_flash_sale_padding',
608 [
609 'label' => esc_html__('Padding (px)', 'shopengine'),
610 'type' => Controls_Manager::DIMENSIONS,
611 'size_units' => ['px'],
612 'default' => [
613 'top' => '0',
614 'right' => '0',
615 'bottom' => '0',
616 'left' => '0',
617 'unit' => 'px',
618 'isLinked' => true,
619 ],
620 'selectors' => [
621 '{{WRAPPER}} .shopengine-related .onsale' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
622 '.rtl {{WRAPPER}} .shopengine-related .onsale' => 'padding: {{TOP}}{{UNIT}} {{LEFT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{RIGHT}}{{UNIT}};',
623 ],
624 'separator' => 'before',
625 ]
626 );
627
628 $this->add_responsive_control(
629 'shopengine_related_product_flash_sale_position',
630 [
631 'label' => esc_html__('Position', 'shopengine'),
632 'type' => Controls_Manager::CHOOSE,
633 'options' => [
634 'left' => [
635 'title' => esc_html__('Left', 'shopengine'),
636 'icon' => 'eicon-h-align-left',
637 ],
638 'right' => [
639 'title' => esc_html__('Right', 'shopengine'),
640 'icon' => 'eicon-h-align-right',
641 ],
642 ],
643 'default' => 'left',
644 'separator' => 'before'
645 ]
646 );
647
648 $this->add_responsive_control(
649 'shopengine_related_product_flash_sale_position_horizontal',
650 [
651 'label' => esc_html__('Horizontal', 'shopengine'),
652 'type' => Controls_Manager::SLIDER,
653 'size_units' => ['px', '%'],
654 'range' => [
655 'px' => [
656 'min' => -100,
657 'max' => 100,
658 'step' => 5,
659 ],
660 '%' => [
661 'min' => 0,
662 'max' => 100,
663 ],
664 ],
665 'default' => [
666 'unit' => 'px',
667 'size' => 20,
668 ],
669 'selectors' => [
670 '{{WRAPPER}} .shopengine-related .related .onsale' => '{{shopengine_related_product_flash_sale_position.VALUE}}: {{SIZE}}{{UNIT}};',
671 ],
672 ]
673 );
674
675 $this->add_responsive_control(
676 'shopengine_related_product_flash_sale_position_vertical',
677 [
678 'label' => esc_html__('Vertical', 'shopengine'),
679 'type' => Controls_Manager::SLIDER,
680 'size_units' => ['px', '%'],
681 'range' => [
682 'px' => [
683 'min' => -100,
684 'max' => 100,
685 'step' => 5,
686 ],
687 '%' => [
688 'min' => 0,
689 'max' => 100,
690 ],
691 ],
692 'default' => [
693 'unit' => 'px',
694 'size' => 20,
695 ],
696 'selectors' => [
697 '{{WRAPPER}} .shopengine-related .related .onsale' => 'top: {{SIZE}}{{UNIT}};',
698 ],
699 ]
700 );
701
702 $this->end_controls_section();
703
704 /*
705 * Style Tab - Products Image
706 */
707 $this->start_controls_section(
708 'shopengine_related_product_image_section',
709 [
710 'label' => esc_html__('Image', 'shopengine'),
711 'tab' => Controls_Manager::TAB_STYLE,
712 ]
713 );
714
715 $this->add_control(
716 'shopengine_related_product_image_bg_color',
717 [
718 'label' => esc_html__('Background Color', 'shopengine'),
719 'type' => Controls_Manager::COLOR,
720 'alpha' => false,
721 'selectors' => [
722 '{{WRAPPER}} .shopengine-related .related .product img' => 'background-color: {{VALUE}};',
723 ],
724 ]
725 );
726
727 $this->add_responsive_control(
728 'shopengine_related_product_image_height',
729 [
730 'label' => esc_html__('Height (px)', 'shopengine'),
731 'description' => esc_html__('Leave empty for auto height', 'shopengine'),
732 'type' => Controls_Manager::SLIDER,
733 'size_units' => ['px'],
734 'range' => [
735 'px' => [
736 'min' => 0,
737 'max' => 500,
738 'step' => 5,
739 ],
740 ],
741 'default' => [
742 'size' => '',
743 ],
744 'selectors' => [
745 '{{WRAPPER}} .shopengine-related .related .product img' => 'height: {{SIZE}}{{UNIT}} !important;',
746 ],
747 ]
748 );
749
750 $this->add_control(
751 'shopengine_related_image_auto_fit',
752 [
753 'label' => esc_html__('Auto Image Fit', 'shopengine'),
754 'type' => Controls_Manager::SWITCHER,
755 'default' => false,
756 'return_value' => true,
757 'selectors' => [
758 '{{WRAPPER}} .shopengine-related .related .product img' => 'object-fit: cover; object-position:center center',
759 ],
760 ]
761 );
762
763 $this->add_responsive_control(
764 'shopengine_related_product_image_padding',
765 [
766 'label' => esc_html__('Padding (px)', 'shopengine'),
767 'type' => Controls_Manager::DIMENSIONS,
768 'size_units' => ['px'],
769 'default' => [
770 'top' => '0',
771 'right' => '0',
772 'bottom' => '8',
773 'left' => '0',
774 'isLinked' => false,
775 ],
776 'selectors' => [
777 '{{WRAPPER}} .shopengine-related .related .product img' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
778 '.rtl {{WRAPPER}} .shopengine-related .related .product img' => 'padding: {{TOP}}{{UNIT}} {{LEFT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{RIGHT}}{{UNIT}};',
779 ],
780 'separator' => 'before',
781 ]
782 );
783
784 $this->end_controls_section();
785
786 /*
787 * Style Tab - Products Title
788 */
789 $this->start_controls_section(
790 'shopengine_related_product_title_section',
791 [
792 'label' => esc_html__('Title', 'shopengine'),
793 'tab' => Controls_Manager::TAB_STYLE,
794 ]
795 );
796
797 $this->add_control(
798 'shopengine_related_product_title_color',
799 [
800 'label' => esc_html__('Color', 'shopengine'),
801 'type' => Controls_Manager::COLOR,
802 'default' => '#101010',
803 'alpha' => false,
804 'selectors' => [
805 '{{WRAPPER}} .shopengine-related .woocommerce-loop-product__title' => 'color: {{VALUE}};',
806 ],
807 ]
808 );
809
810 $this->add_group_control(
811 Group_Control_Typography::get_type(),
812 [
813 'name' => 'shopengine_related_product_title_typography',
814 'label' => esc_html__('Typography', 'shopengine'),
815 'selector' => '{{WRAPPER}} .shopengine-related .woocommerce-loop-product__title',
816 'exclude' => ['font_family', 'letter_spacing', 'text_decoration', 'font_style'],
817 'fields_options' => [
818 'typography' => [
819 'default' => 'custom',
820 ],
821 'font_weight' => [
822 'default' => '500',
823 ],
824 'font_size' => [
825 'label' => esc_html__('Font Size (px)', 'shopengine'),
826 'default' => [
827 'size' => '15',
828 'unit' => 'px',
829 ],
830 'size_units' => ['px'],
831 ],
832 'text_transform' => [
833 'default' => 'none',
834 ],
835 'line_height' => [
836 'label' => esc_html__('Line Height (px)', 'shopengine'),
837 'default' => [
838 'size' => '20',
839 'unit' => 'px',
840 ],
841 'size_units' => ['px'],
842 'tablet_default' => [
843 'unit' => 'px',
844 ],
845 'mobile_default' => [
846 'unit' => 'px',
847 ],
848 ],
849 ],
850 ]
851 );
852
853 $this->add_responsive_control(
854 'shopengine_related_product_title_padding',
855 [
856 'label' => esc_html__('Padding (px)', 'shopengine'),
857 'type' => Controls_Manager::DIMENSIONS,
858 'size_units' => ['px'],
859 'default' => [
860 'top' => '0',
861 'right' => '0',
862 'bottom' => '8',
863 'left' => '0',
864 'isLinked' => false,
865 ],
866 'selectors' => [
867 '{{WRAPPER}} .shopengine-related .woocommerce-loop-product__title' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
868 '.rtl {{WRAPPER}} .shopengine-related .woocommerce-loop-product__title' => 'padding: {{TOP}}{{UNIT}} {{LEFT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{RIGHT}}{{UNIT}};',
869 ],
870 'separator' => 'before',
871 ]
872 );
873
874 $this->end_controls_section();
875
876 /*
877 * Style Tab - Products Rating
878 */
879 $this->start_controls_section(
880 'shopengine_related_product_rating_section',
881 [
882 'label' => esc_html__('Rating', 'shopengine'),
883 'tab' => Controls_Manager::TAB_STYLE,
884 ]
885 );
886
887 $this->add_control(
888 'shopengine_related_product_rating_start_color',
889 [
890 'label' => esc_html__('Color', 'shopengine'),
891 'type' => Controls_Manager::COLOR,
892 'default' => '#fec42d',
893 'alpha' => false,
894 'selectors' => [
895 '{{WRAPPER}} .shopengine-related .products .star-rating' => 'color: {{VALUE}};',
896 '{{WRAPPER}} .shopengine-related .products .star-rating::before' => 'color: {{VALUE}};',
897 ],
898 ]
899 );
900
901 $this->add_responsive_control(
902 'shopengine_related_product_rating_start_size',
903 [
904 'label' => esc_html__('Star Size (px)', 'shopengine'),
905 'type' => Controls_Manager::SLIDER,
906 'size_units' => ['px'],
907 'range' => [
908 'px' => [
909 'min' => 0,
910 'max' => 50,
911 'step' => 1,
912 ],
913 ],
914 'default' => [
915 'unit' => 'px',
916 'size' => 12,
917 ],
918 'selectors' => [
919 '{{WRAPPER}} .shopengine-related .products .star-rating' => 'font-size: {{SIZE}}{{UNIT}};',
920 ],
921 ]
922 );
923
924 $this->add_responsive_control(
925 'shopengine_related_product_rating_start_margin',
926 [
927 'label' => esc_html__('Margin (px)', 'shopengine'),
928 'type' => Controls_Manager::DIMENSIONS,
929 'size_units' => ['px'],
930 'default' => [
931 'top' => '0',
932 'right' => '0',
933 'bottom' => '8',
934 'left' => '0',
935 'isLinked' => false,
936 ],
937 'selectors' => [
938 '{{WRAPPER}} .shopengine-related .products .star-rating' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
939 '.rtl {{WRAPPER}} .shopengine-related .products .star-rating' => 'margin: {{TOP}}{{UNIT}} {{LEFT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{RIGHT}}{{UNIT}};',
940 ],
941 'separator' => 'before',
942 ]
943 );
944
945 $this->end_controls_section();
946
947 /*
948 * Style Tab - Products Price
949 */
950 $this->start_controls_section(
951 'shopengine_related_product_price_section',
952 [
953 'label' => esc_html__('Price', 'shopengine'),
954 'tab' => Controls_Manager::TAB_STYLE,
955 ]
956 );
957
958 $this->add_control(
959 'shopengine_related_product_price_color',
960 [
961 'label' => esc_html__('Color', 'shopengine'),
962 'type' => Controls_Manager::COLOR,
963 'default' => '#101010',
964 'alpha' => false,
965 'selectors' => [
966 '{{WRAPPER}} .shopengine-related :is(.price .amount)' => 'color: {{VALUE}};',
967 ],
968 ]
969 );
970
971 $this->add_control(
972 'shopengine_related_product_sale_price_color',
973 [
974 'label' => esc_html__('Sale Price Color', 'shopengine'),
975 'type' => Controls_Manager::COLOR,
976 'default' => '#101010',
977 'alpha' => false,
978 'selectors' => [
979 '{{WRAPPER}} .shopengine-related .price :is(del, del span, del .amount)' => 'color: {{VALUE}};',
980 ],
981 'condition' => [
982 'shopengine_related_product_show_sale_price' => 'yes',
983 ],
984 ]
985 );
986
987 $this->add_group_control(
988 Group_Control_Typography::get_type(),
989 [
990 'name' => 'shopengine_related_product_price_typography',
991 'selector' => '{{WRAPPER}} .shopengine-related :is(.price, .price .amount, .price ins, .price del)',
992 'exclude' => ['text_transform', 'text_decoration', 'font_style', 'letter_spacing'],
993 'fields_options' => [
994 'typography' => [
995 'default' => 'custom',
996 ],
997 'font_weight' => [
998 'default' => '700',
999 ],
1000 'font_size' => [
1001 'label' => esc_html__('Font Size (px)', 'shopengine'),
1002 'size_units' => ['px'],
1003 'default' => [
1004 'size' => '18',
1005 'unit' => 'px'
1006 ]
1007 ],
1008 'line_height' => [
1009 'label' => esc_html__('Line Height (px)', 'shopengine'),
1010 'default' => [
1011 'size' => '24',
1012 'unit' => 'px',
1013 ],
1014 'size_units' => ['px'],
1015 'tablet_default' => [
1016 'unit' => 'px',
1017 ],
1018 'mobile_default' => [
1019 'unit' => 'px',
1020 ],
1021 ],
1022 ],
1023 ]
1024 );
1025
1026 $this->add_responsive_control(
1027 'shopengine_related_product_price_padding',
1028 [
1029 'label' => esc_html__('Padding (px)', 'shopengine'),
1030 'type' => Controls_Manager::DIMENSIONS,
1031 'size_units' => ['px'],
1032 'default' => [
1033 'top' => '0',
1034 'right' => '0',
1035 'bottom' => '8',
1036 'left' => '0',
1037 'isLinked' => false,
1038 ],
1039 'selectors' => [
1040 '{{WRAPPER}} .shopengine-related .price' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
1041 '.rtl {{WRAPPER}} .shopengine-related .price' => 'padding: {{TOP}}{{UNIT}} {{LEFT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{RIGHT}}{{UNIT}};',
1042 ],
1043 'separator' => 'before',
1044 ]
1045 );
1046
1047 $this->end_controls_section();
1048
1049 /*
1050 * Style Tab - Products Rating
1051 */
1052 $this->start_controls_section(
1053 'shopengine_related_product_add_cart_btn_section',
1054 [
1055 'label' => esc_html__('Add To Cart', 'shopengine'),
1056 'tab' => Controls_Manager::TAB_STYLE,
1057 'condition' => [
1058 'shopengine_related_product_show_cart_btn' => 'yes',
1059 ],
1060 ]
1061 );
1062
1063 $this->add_group_control(
1064 Group_Control_Typography::get_type(),
1065 [
1066 'name' => 'shopengine_related_product_add_cart_typography',
1067 'label' => esc_html__('Typography', 'shopengine'),
1068 'selector' => '{{WRAPPER}} .shopengine-related .related :is(.button, .added_to_cart)',
1069 'exclude' => ['font_family', 'letter_spacing', 'text_decoration', 'font_style'],
1070 'fields_options' => [
1071 'typography' => [
1072 'default' => 'custom',
1073 ],
1074 'font_weight' => [
1075 'default' => '500',
1076 ],
1077 'font_size' => [
1078 'default' => [
1079 'size' => '13',
1080 'unit' => 'px',
1081 ],
1082 'size_units' => ['px'],
1083 ],
1084 'text_transform' => [
1085 'default' => 'uppercase',
1086 ],
1087 'line_height' => [
1088 'label' => esc_html__('Line Height (px)', 'shopengine'),
1089 'default' => [
1090 'size' => '18',
1091 'unit' => 'px',
1092 ],
1093 'size_units' => ['px'],
1094 'tablet_default' => [
1095 'unit' => 'px',
1096 ],
1097 'mobile_default' => [
1098 'unit' => 'px',
1099 ],
1100 ],
1101 ],
1102 'separator' => 'before',
1103 ]
1104 );
1105
1106 $this->add_control(
1107 'shopengine_related_button_move_end',
1108 [
1109 'label' => esc_html__('Position End', 'shopengine'),
1110 'type' => Controls_Manager::SWITCHER,
1111 'default' => false,
1112 'return_value' => true,
1113 'selectors' => [
1114 '{{WRAPPER}} .shopengine-related .related :is(.button, .added_to_cart)' => 'order: 1',
1115 ],
1116 ]
1117 );
1118
1119 $this->start_controls_tabs(
1120 'shopengine_related_product_add_cart_btn_style_tabs',
1121 [
1122 'separator' => 'before',
1123 ]
1124 );
1125
1126 $this->start_controls_tab(
1127 'shopengine_related_product_add_cart_btn_tab_normal',
1128 [
1129 'label' => esc_html__('Normal', 'shopengine'),
1130 ]
1131 );
1132
1133 $this->add_control(
1134 'shopengine_related_product_add_cart_btn_color',
1135 [
1136 'label' => esc_html__('Text Color', 'shopengine'),
1137 'type' => Controls_Manager::COLOR,
1138 'default' => '#FFFFFF',
1139 'alpha' => false,
1140 'selectors' => [
1141 '{{WRAPPER}} .shopengine-related .related :is(.button, .added_to_cart)' => 'color: {{VALUE}} !important;',
1142 ],
1143 ]
1144 );
1145
1146 $this->add_control(
1147 'shopengine_related_product_add_cart_btn_bg_color',
1148 [
1149 'label' => esc_html__('Background Color', 'shopengine'),
1150 'type' => Controls_Manager::COLOR,
1151 'default' => '#3E3E3E',
1152 'alpha' => false,
1153 'selectors' => [
1154 '{{WRAPPER}} .shopengine-related .related :is(.button, .added_to_cart)' => 'background-color: {{VALUE}} !important;',
1155 ],
1156 ]
1157 );
1158
1159 $this->end_controls_tab();
1160
1161 $this->start_controls_tab(
1162 'shopengine_related_product_add_cart_btn_tab_hover',
1163 [
1164 'label' => esc_html__('Hover', 'shopengine'),
1165 ]
1166 );
1167
1168 $this->add_control(
1169 'shopengine_related_product_add_cart_btn_hover_color',
1170 [
1171 'label' => esc_html__('Text Color', 'shopengine'),
1172 'type' => Controls_Manager::COLOR,
1173 'default' => '#FFFFFF',
1174 'alpha' => false,
1175 'selectors' => [
1176 '{{WRAPPER}} .shopengine-related .related :is(.button, .added_to_cart):hover' => 'color: {{VALUE}} !important;',
1177 ],
1178 ]
1179 );
1180
1181 $this->add_control(
1182 'shopengine_related_product_add_cart_btn_hover_bg_color',
1183 [
1184 'label' => esc_html__('Background Color', 'shopengine'),
1185 'type' => Controls_Manager::COLOR,
1186 'default' => '#332d2d',
1187 'alpha' => false,
1188 'selectors' => [
1189 '{{WRAPPER}} .shopengine-related .related :is(.button, .added_to_cart):hover' => 'background-color: {{VALUE}} !important;',
1190 ],
1191 ]
1192 );
1193
1194 $this->add_control(
1195 'shopengine_related_product_add_cart_btn_hover_border_color',
1196 [
1197 'label' => esc_html__('Border Color', 'shopengine'),
1198 'type' => Controls_Manager::COLOR,
1199 'selectors' => [
1200 '{{WRAPPER}} .shopengine-related .related :is(.button, .added_to_cart):hover' => 'border-color: {{VALUE}} !important;',
1201 ],
1202 ]
1203 );
1204
1205 $this->end_controls_tab();
1206 $this->end_controls_tabs();
1207
1208 $this->add_responsive_control(
1209 'shopengine_related_product_add_cart_btn_padding',
1210 [
1211 'label' => esc_html__('Padding (px)', 'shopengine'),
1212 'type' => Controls_Manager::DIMENSIONS,
1213 'size_units' => ['px'],
1214 'default' => [
1215 'top' => '8',
1216 'right' => '15',
1217 'bottom' => '8',
1218 'left' => '15',
1219 'unit' => 'px',
1220 'isLinked' => false,
1221 ],
1222 'selectors' => [
1223 '{{WRAPPER}} .shopengine-related .related :is(.button, .added_to_cart)' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
1224 '.rtl {{WRAPPER}} .shopengine-related .related :is(.button, .added_to_cart)' => 'padding: {{TOP}}{{UNIT}} {{LEFT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{RIGHT}}{{UNIT}};',
1225 ],
1226 'separator' => 'before',
1227 ]
1228 );
1229
1230 $this->add_group_control(
1231 Group_Control_Border::get_type(),
1232 [
1233 'name' => 'shopengine_related_product_add_cart_border',
1234 'label' => esc_html__('Border', 'shopengine'),
1235 'selector' => '{{WRAPPER}} .shopengine-related .related :is(.button, .added_to_cart)',
1236 'separator' => 'before',
1237 'fields_options' => [
1238 'border' => [
1239 'selectors' => [
1240 '{{WRAPPER}} .shopengine-related .related :is(.button, .added_to_cart)' => 'border-style: {{VALUE}} !important;',
1241 ],
1242 ],
1243 'width' => [
1244 'selectors' => [
1245 '{{WRAPPER}} .shopengine-related .related :is(.button, .added_to_cart)' => 'border-width: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}} !important;',
1246 '.rtl {{WRAPPER}} .shopengine-related .related :is(.button, .added_to_cart)' => 'border-width: {{TOP}}{{UNIT}} {{LEFT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{RIGHT}}{{UNIT}} !important;',
1247 ],
1248 ],
1249 'color' => [
1250 'selectors' => [
1251 '{{WRAPPER}} .shopengine-related .related :is(.button, .added_to_cart)' => 'border-color: {{VALUE}} !important;',
1252 ],
1253 ]
1254 ],
1255 ]
1256 );
1257
1258 $this->add_control(
1259 'shopengine_related_product_add_cart_border_radius',
1260 [
1261 'label' => esc_html__('Border Radius (px)', 'shopengine'),
1262 'type' => Controls_Manager::DIMENSIONS,
1263 'size_units' => ['px'],
1264 'default' => [
1265 'top' => '0',
1266 'right' => '0',
1267 'bottom' => '0',
1268 'left' => '0',
1269 'unit' => 'px',
1270 'isLinked' => true,
1271 ],
1272 'selectors' => [
1273 '{{WRAPPER}} .shopengine-related .related :is(.button, .added_to_cart)' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}} !important;',
1274 '.rtl {{WRAPPER}} .shopengine-related .related :is(.button, .added_to_cart)' => 'border-radius: {{TOP}}{{UNIT}} {{LEFT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{RIGHT}}{{UNIT}} !important;',
1275 ],
1276 ]
1277 );
1278
1279 $this->add_responsive_control(
1280 'shopengine_related_product_add_cart_btn_margin',
1281 [
1282 'label' => esc_html__('Margin (px)', 'shopengine'),
1283 'type' => Controls_Manager::DIMENSIONS,
1284 'size_units' => ['px'],
1285 'default' => [
1286 'top' => '0',
1287 'right' => '0',
1288 'bottom' => '0',
1289 'left' => '0',
1290 'isLinked' => false,
1291 ],
1292 'selectors' => [
1293 '{{WRAPPER}} .shopengine-related .related :is(.button, .added_to_cart)' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}} !important;',
1294 '.rtl {{WRAPPER}} .shopengine-related .related :is(.button, .added_to_cart)' => 'margin: {{TOP}}{{UNIT}} {{LEFT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{RIGHT}}{{UNIT}} !important;',
1295 ],
1296 'separator' => 'before',
1297 ]
1298 );
1299
1300 $this->end_controls_section();
1301
1302 /*
1303 * Style Tab - Slider
1304 */
1305 $this->start_controls_section(
1306 'shopengine_related_product_slider_style_section',
1307 [
1308 'label' => esc_html__('Slider Style', 'shopengine'),
1309 'tab' => Controls_Manager::TAB_STYLE,
1310 'conditions' => [
1311 'relation' => 'and',
1312 'terms' => [
1313 [
1314 'name' => 'shopengine_related_product_enable_slider',
1315 'operator' => '===',
1316 'value' => 'yes'
1317 ],
1318 [
1319 'relation' => 'or',
1320 'terms' => [
1321 [
1322 'name' => 'shopengine_related_product_slider_show_arrows',
1323 'operator' => '===',
1324 'value' => 'yes'
1325 ],
1326 [
1327 'name' => 'shopengine_related_product_slider_show_dots',
1328 'operator' => '===',
1329 'value' => 'yes'
1330 ]
1331 ]
1332 ]
1333 ]
1334 ]
1335 ]
1336 );
1337
1338 $this->add_control(
1339 'shopengine_related_product_slider_arrows_style',
1340 [
1341 'label' => esc_html__( 'Arrows', 'shopengine' ),
1342 'type' => Controls_Manager::HEADING,
1343 'condition' => [
1344 'shopengine_related_product_slider_show_arrows' => 'yes',
1345 ],
1346 ]
1347 );
1348
1349 $this->add_control(
1350 'shopengine_related_product_slider_arrow_icon_size',
1351 [
1352 'label' => esc_html__('Icon Size (px)', 'shopengine'),
1353 'type' => Controls_Manager::SLIDER,
1354 'size_units' => ['px'],
1355 'range' => [
1356 'px' => [
1357 'min' => 0,
1358 'max' => 100,
1359 'step' => 5,
1360 ],
1361 ],
1362 'default' => [
1363 'unit' => 'px',
1364 'size' => 25,
1365 ],
1366 'selectors' => [
1367 '{{WRAPPER}} .shopengine-related :is(.swiper-button-prev, .swiper-button-next)' => 'font-size: {{SIZE}}{{UNIT}};',
1368 '{{WRAPPER}} .shopengine-related :is(.swiper-button-prev svg, .swiper-button-next svg)' => 'width: {{SIZE}}{{UNIT}};',
1369 ],
1370 'condition' => [
1371 'shopengine_related_product_slider_show_arrows' => 'yes',
1372 ],
1373 ]
1374 );
1375
1376 $this->add_control(
1377 'shopengine_related_product_slider_arrow_size',
1378 [
1379 'label' => esc_html__('Arrow Size (px)', 'shopengine'),
1380 'type' => Controls_Manager::SLIDER,
1381 'size_units' => ['px'],
1382 'range' => [
1383 'px' => [
1384 'min' => 0,
1385 'max' => 100,
1386 'step' => 5,
1387 ],
1388 ],
1389 'default' => [
1390 'unit' => 'px',
1391 'size' => 40,
1392 ],
1393 'selectors' => [
1394 '{{WRAPPER}} .shopengine-related :is(.swiper-button-next, .swiper-button-prev)' => 'width: {{SIZE}}{{UNIT}};height: {{SIZE}}{{UNIT}}; line-height: {{SIZE}}{{UNIT}};',
1395 ],
1396 'condition' => [
1397 'shopengine_related_product_slider_show_arrows' => 'yes',
1398 ],
1399 'separator' => 'before',
1400 ]
1401 );
1402
1403 $this->start_controls_tabs(
1404 'shopengine_related_product_slider_arrows_tabs',
1405 [
1406 'condition' => [
1407 'shopengine_related_product_slider_show_arrows' => 'yes',
1408 ],
1409 ]
1410 );
1411
1412 $this->start_controls_tab(
1413 'shopengine_related_product_slider_arrows_tab_normal',
1414 [
1415 'label' => esc_html__('Normal', 'shopengine'),
1416 ]
1417 );
1418
1419 $this->add_control(
1420 'shopengine_related_product_slider_arrows_color',
1421 [
1422 'label' => esc_html__('Color', 'shopengine'),
1423 'type' => Controls_Manager::COLOR,
1424 'default' => '#FFFFFF',
1425 'alpha' => false,
1426 'selectors' => [
1427 '{{WRAPPER}} .shopengine-related :is(.swiper-button-prev, .swiper-button-next)' => 'color: {{VALUE}};',
1428 '{{WRAPPER}} .shopengine-related :is(.swiper-button-prev svg, .swiper-button-next svg)' => 'fill: {{VALUE}};',
1429 ],
1430 ]
1431 );
1432
1433 $this->add_control(
1434 'shopengine_related_product_slider_arrows_bg_color',
1435 [
1436 'label' => esc_html__('Background Color', 'shopengine'),
1437 'type' => Controls_Manager::COLOR,
1438 'default' => '#3E3E3E',
1439 'selectors' => [
1440 '{{WRAPPER}} .shopengine-related :is(.swiper-button-prev, .swiper-button-next)' => 'background-color: {{VALUE}};',
1441 ],
1442 ]
1443 );
1444
1445 $this->end_controls_tab();
1446
1447 $this->start_controls_tab(
1448 'shopengine_related_product_slider_arrows_tab_hover',
1449 [
1450 'label' => esc_html__('Hover', 'shopengine'),
1451 ]
1452 );
1453
1454 $this->add_control(
1455 'shopengine_related_product_slider_arrows_hover_color',
1456 [
1457 'label' => esc_html__('Color', 'shopengine'),
1458 'type' => Controls_Manager::COLOR,
1459 'default' => '#FFFFFF',
1460 'alpha' => false,
1461 'selectors' => [
1462 '{{WRAPPER}} .shopengine-related :is(.swiper-button-prev, .swiper-button-next):hover' => 'color: {{VALUE}};',
1463 ],
1464 ]
1465 );
1466
1467 $this->add_control(
1468 'shopengine_related_product_slider_arrows_hover_bg_color',
1469 [
1470 'label' => esc_html__('Background Color', 'shopengine'),
1471 'type' => Controls_Manager::COLOR,
1472 'default' => '#332d2d',
1473 'selectors' => [
1474 '{{WRAPPER}} .shopengine-related :is(.swiper-button-prev, .swiper-button-next):hover' => 'background-color: {{VALUE}};',
1475 ],
1476 ]
1477 );
1478
1479 $this->add_control(
1480 'shopengine_related_product_slider_arrows_hover_border_color',
1481 [
1482 'label' => esc_html__('Border Color', 'shopengine'),
1483 'type' => Controls_Manager::COLOR,
1484 'selectors' => [
1485 '{{WRAPPER}} .shopengine-related :is(.swiper-button-prev, .swiper-button-next):hover' => 'border-color: {{VALUE}};',
1486 ],
1487 ]
1488 );
1489
1490 $this->end_controls_tab();
1491 $this->end_controls_tabs();
1492
1493 $this->add_group_control(
1494 Group_Control_Border::get_type(),
1495 [
1496 'name' => 'shopengine_related_product_slider_arrows_border',
1497 'label' => esc_html__('Border', 'shopengine'),
1498 'selector' => '{{WRAPPER}} .shopengine-related :is(.swiper-button-prev, .swiper-button-next)',
1499 'condition' => [
1500 'shopengine_related_product_slider_show_arrows' => 'yes',
1501 ],
1502 'separator' => 'before',
1503 ]
1504 );
1505
1506 $this->add_control(
1507 'shopengine_related_product_slider_arrows_border_radius',
1508 [
1509 'label' => esc_html__('Border Radius (px)', 'shopengine'),
1510 'type' => Controls_Manager::DIMENSIONS,
1511 'size_units' => ['px'],
1512 'default' => [
1513 'top' => '0',
1514 'right' => '0',
1515 'bottom' => '0',
1516 'left' => '0',
1517 'unit' => 'px',
1518 'isLinked' => true,
1519 ],
1520 'selectors' => [
1521 '{{WRAPPER}} .shopengine-related :is(.swiper-button-prev, .swiper-button-next)' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
1522 '.rtl {{WRAPPER}} .shopengine-related :is(.swiper-button-prev, .swiper-button-next)' => 'border-radius: {{TOP}}{{UNIT}} {{LEFT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{RIGHT}}{{UNIT}};',
1523 ],
1524 'condition' => [
1525 'shopengine_related_product_slider_show_arrows' => 'yes',
1526 ],
1527 ]
1528 );
1529
1530 $this->add_control(
1531 'shopengine_related_product_slider_style_divider',
1532 [
1533 'type' => Controls_Manager::DIVIDER,
1534 'conditions' => [
1535 'relation' => 'and',
1536 'terms' => [
1537 [
1538 'name' => 'shopengine_related_product_slider_show_arrows',
1539 'operator' => '===',
1540 'value' => 'yes'
1541 ],
1542 [
1543 'name' => 'shopengine_related_product_slider_show_dots',
1544 'operator' => '===',
1545 'value' => 'yes'
1546 ]
1547 ]
1548 ]
1549 ]
1550 );
1551
1552 $this->add_control(
1553 'shopengine_related_product_slider_dots_style',
1554 [
1555 'label' => esc_html__( 'Dots', 'shopengine' ),
1556 'type' => Controls_Manager::HEADING,
1557 'condition' => [
1558 'shopengine_related_product_slider_show_dots' => 'yes',
1559 ],
1560 ]
1561 );
1562
1563 $this->add_control(
1564 'shopengine_related_product_slider_dots_color',
1565 [
1566 'label' => esc_html__('Color', 'shopengine'),
1567 'type' => Controls_Manager::COLOR,
1568 'default' => '#c9c9c9',
1569 'alpha' => false,
1570 'selectors' => [
1571 '{{WRAPPER}} .shopengine-related .swiper-pagination-bullet' => 'background: {{VALUE}};',
1572 ],
1573 'condition' => [
1574 'shopengine_related_product_slider_show_dots' => 'yes',
1575 ],
1576 ]
1577 );
1578
1579 $this->add_control(
1580 'shopengine_related_product_slider_active_dots_color',
1581 [
1582 'label' => esc_html__('Active Color', 'shopengine'),
1583 'type' => Controls_Manager::COLOR,
1584 'default' => '#f03d3f',
1585 'alpha' => false,
1586 'selectors' => [
1587 '{{WRAPPER}} .shopengine-related .swiper-pagination-bullet-active' => 'border-color: {{VALUE}};',
1588 ],
1589 'condition' => [
1590 '$shopengine_related_product_slider_show_dots' => 'yes',
1591 ],
1592 ]
1593 );
1594
1595 $this->add_responsive_control(
1596 'shopengine_related_product_slider_dot_wrap_margin',
1597 [
1598 'label' => esc_html__('Wrap Margin (px)', 'shopengine'),
1599 'type' => Controls_Manager::DIMENSIONS,
1600 'size_units' => ['px'],
1601 'default' => [
1602 'top' => '20',
1603 'right' => '0',
1604 'bottom' => '0',
1605 'left' => '0',
1606 'isLinked' => false,
1607 ],
1608 'selectors' => [
1609 '{{WRAPPER}} .shopengine-related .swiper-pagination' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
1610 '.rtl {{WRAPPER}} .shopengine-related .swiper-pagination' => 'margin: {{TOP}}{{UNIT}} {{LEFT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{RIGHT}}{{UNIT}};',
1611 ],
1612 'condition' => [
1613 '$shopengine_related_product_slider_show_dots' => 'yes',
1614 ],
1615 'separator' => 'before',
1616 ]
1617 );
1618
1619 $this->end_controls_section();
1620
1621 /*
1622 * Style Tab - Global Font
1623 */
1624 $this->start_controls_section(
1625 'shopengine_related_product_global_font_section',
1626 [
1627 'label' => esc_html__('Global Font', 'shopengine'),
1628 'tab' => Controls_Manager::TAB_STYLE,
1629 ]
1630 );
1631
1632 $this->add_control(
1633 'shopengine_related_product_global_font_family',
1634 [
1635 'label' => esc_html__('Font Family', 'shopengine'),
1636 'description' => esc_html__('This font family is set for this specific widget.', 'shopengine'),
1637 'type' => Controls_Manager::FONT,
1638 'selectors' => [
1639 '{{WRAPPER}} .shopengine-related .related :is(.onsale, .woocommerce-loop-product__title, .price, del, ins, .button)' => 'font-family: {{VALUE}};',
1640 ],
1641 ]
1642 );
1643
1644 $this->end_controls_section();
1645 }
1646
1647 public function get_icon_html($icon) {
1648
1649 if($icon) {
1650 ob_start();
1651 \Elementor\Icons_Manager::render_icon($icon, ['aria-hidden' => 'true']);
1652 $icon = ob_get_clean();
1653 } else {
1654 $icon = '';
1655 }
1656
1657 return $icon;
1658 }
1659
1660 protected function screen() {
1661
1662 $settings = $this->get_settings_for_display();
1663 shopengine_content_render(\ShopEngine\Utils\Helper::render($this->render_view($settings)));
1664 }
1665
1666 protected function render_view($settings = []) {
1667
1668 extract($settings);
1669
1670 $post_type = get_post_type();
1671
1672 $product = Products::instance()->get_product($post_type);
1673
1674 if(empty($product)) {
1675 return;
1676 }
1677
1678 $is_slider_enable = ($shopengine_related_product_enable_slider == "yes") ? true : false;
1679
1680 $args = [
1681 'posts_per_page' => $shopengine_related_product_to_show,
1682 'columns' => $is_slider_enable ? $shopengine_related_product_slider_perview : $shopengine_related_product_columns,
1683 'orderby' => $shopengine_related_product_orderby,
1684 'order' => $shopengine_related_product_order,
1685 ];
1686
1687
1688 if(\Elementor\Plugin::$instance->editor->is_edit_mode() || is_preview()) {
1689
1690 $argument = array(
1691 'type' => ['simple'],
1692 'limit' => $shopengine_related_product_to_show,
1693 );
1694
1695 $parent_product_array = wc_get_products($argument);
1696
1697 $crosssell_products = [];
1698 foreach($parent_product_array as $prod) {
1699 $crosssell_products[] = $prod->get_id();
1700 }
1701
1702 add_filter('woocommerce_related_products', function ($prod_ids) use ($crosssell_products) {
1703
1704 return $prod_ids;
1705 });
1706 }
1707
1708 $args['related_products'] = array_filter(array_map('wc_get_product', wc_get_related_products($product->get_id(), $args['posts_per_page'], $product->get_upsell_ids())), 'wc_products_array_filter_visible');
1709
1710 // Handle orderby.
1711 $args['related_products'] = wc_products_array_orderby($args['related_products'], $args['orderby'], $args['order']);
1712
1713 if (is_array($args['related_products'])) {
1714 // Get the count of related products
1715 $related_product_count = count($args['related_products']);
1716
1717 // Set the slider loop option based on the related product count and $shopengine_related_product_slider_loop value
1718 $slider_loop = ($related_product_count > 1 && $shopengine_related_product_slider_loop === "yes") ? true : false;
1719 } else {
1720 // Set a default value for slider loop if $args['related_products'] is not an array
1721 $slider_loop = false;
1722 }
1723 // slider controls for the template file
1724 $slider_options = [
1725 'slider_enabled' => true,
1726 'slides_to_show' => $shopengine_related_product_slider_perview,
1727 'slides_to_show_mobile' => isset( $shopengine_related_product_slider_perview_mobile ) ? $shopengine_related_product_slider_perview_mobile : 1,
1728 'slides_to_show_tablet' => isset( $shopengine_related_product_slider_perview_tablet ) ? $shopengine_related_product_slider_perview_tablet: 2,
1729 'slider_loop' => $slider_loop,
1730 'slider_autoplay' => ($shopengine_related_product_slider_autoplay === "yes") ? true : false,
1731 'slider_autoplay_delay' => $shopengine_related_product_slider_autoplay_delay,
1732 'slider_space_between' => $shopengine_related_product_column_gap['size']
1733 ];
1734
1735 //passing slider controls to the template file
1736 $encode_slider_options = \json_encode($slider_options);
1737
1738 $tpl = Products::instance()->get_widget_template($this->get_name());
1739
1740 include $tpl;
1741 }
1742 }
1743