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