PluginProbe
SellKit – Funnel builder and checkout optimizer for WooCommerce to sell more, faster / 1.2.2
SellKit – Funnel builder and checkout optimizer for WooCommerce to sell more, faster v1.2.2
2.7.0 2.6.0 trunk 1.1.0 1.1.4 1.2.1 1.2.2 1.2.3 1.2.5 1.2.9 1.3.1 1.3.2 1.5.0 1.5.1 1.5.4 1.5.7 1.5.8 1.5.9 1.6.2 1.6.5 1.6.8 1.7.2 1.7.4 1.7.5 1.7.9 All 43 releases
sellkit / includes / elementor / modules / product-images / widgets / product-images.php

product-images.php in SellKit – Funnel builder and checkout optimizer for WooCommerce to sell more, faster 1.2.2, at includes/elementor/modules/product-images/widgets/product-images.php

391 lines 9.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 use Elementor\Settings;
4
5 defined( 'ABSPATH' ) || die();
6
7 class Sellkit_Elementor_Product_Images_Widget extends Sellkit_Elementor_Upsell_Base_Widget {
8
9 public function get_script_depends() {
10 return [ 'zoom', 'flexslider', 'photoswipe', 'photoswipe-ui-default', 'wc-single-product' ];
11 }
12
13 public function get_style_depends() {
14 return [ 'photoswipe', 'photoswipe-default-skin' ];
15 }
16
17 public static function is_active() {
18 return class_exists( 'woocommerce' );
19 }
20
21 public function get_name() {
22 return 'sellkit-product-images';
23 }
24
25 public function get_title() {
26 return __( 'Product Images', 'sellkit' );
27 }
28
29 public function get_icon() {
30 return 'sellkit-element-icon sellkit-product-images-icon';
31 }
32
33 protected function register_controls() {
34 $this->register_content_box_controls();
35
36 $this->start_controls_section(
37 'style',
38 [
39 'label' => __( 'Style', 'sellkit' ),
40 'tab' => 'style',
41 ]
42 );
43
44 $this->add_control(
45 'border_type',
46 [
47 'label' => __( 'Border Type', 'sellkit' ),
48 'type' => 'select',
49 'options' => [
50 '' => __( 'None', 'sellkit' ),
51 'solid' => __( 'Solid', 'sellkit' ),
52 'double' => __( 'Double', 'sellkit' ),
53 'dotted' => __( 'Dotted', 'sellkit' ),
54 'dashed' => __( 'Dashed', 'sellkit' ),
55 'groove' => __( 'Groove', 'sellkit' ),
56 ],
57 'selectors' => [
58 '{{WRAPPER}} .product.product-images-is-slider .flex-viewport' => 'border-style: {{VALUE}} !important;',
59 '{{WRAPPER}} .product:not(.product-images-is-slider) .woocommerce-product-gallery__wrapper' => 'border-style: {{VALUE}} !important;',
60 ],
61 ]
62 );
63
64 $this->add_control(
65 'border_color',
66 [
67 'label' => __( 'Border Color', 'sellkit' ),
68 'type' => 'color',
69 'selectors' => [
70 '{{WRAPPER}} .product.product-images-is-slider .flex-viewport' => 'border-color: {{VALUE}} !important;',
71 '{{WRAPPER}} .product:not(.product-images-is-slider) .woocommerce-product-gallery__wrapper' => 'border-color: {{VALUE}} !important;',
72 ],
73 'condition' => [
74 'border_type!' => '',
75 ],
76 ]
77 );
78
79 $this->add_responsive_control(
80 'border_width',
81 [
82 'label' => __( 'Border Width', 'sellkit' ),
83 'type' => 'slider',
84 'size_units' => [ 'px' ],
85 'default' => [
86 'size' => 1,
87 ],
88 'range' => [
89 'px' => [
90 'min' => 0,
91 'max' => 100,
92 ],
93 ],
94 'selectors' => [
95 '{{WRAPPER}} .product.product-images-is-slider .flex-viewport' => 'border-width: {{SIZE}}{{UNIT}} !important;',
96 '{{WRAPPER}} .product:not(.product-images-is-slider) .woocommerce-product-gallery__wrapper' => 'border-width: {{SIZE}}{{UNIT}} !important;',
97 ],
98 'condition' => [
99 'border_type!' => '',
100 ],
101 ]
102 );
103
104 $this->add_responsive_control(
105 'border_radius',
106 [
107 'label' => __( 'Border Radius', 'sellkit' ),
108 'type' => 'dimensions',
109 'size_units' => [ 'px', '%' ],
110 'default' => [
111 'unit' => 'px',
112 ],
113 'selectors' => [
114 '{{WRAPPER}} .product.product-images-is-slider .flex-viewport' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
115 '{{WRAPPER}} .product:not(.product-images-is-slider) .woocommerce-product-gallery__wrapper' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
116 ],
117 ]
118 );
119
120 $this->add_control(
121 'bottom_spacing',
122 [
123 'label' => __( 'Spacing', 'sellkit' ),
124 'type' => 'slider',
125 'default' => [
126 'size' => 10,
127 ],
128 'description' => __( 'Between main image and gallery slider(If slider available)', 'jupitrex-core' ),
129 'selectors' => [
130 '{{WRAPPER}} .flex-viewport' => 'margin-bottom: {{SIZE}}{{UNIT}};',
131 ],
132 'condition' => [
133 'slider_switch' => 'yes',
134 ],
135 ]
136 );
137
138 $this->add_responsive_control(
139 'gallery_width',
140 [
141 'label' => __( 'Width', 'sellkit' ),
142 'type' => 'slider',
143 'size_units' => [ '%', 'px' ],
144 'render_type' => 'template',
145 'default' => [
146 'unit' => '%',
147 'size' => 100,
148 ],
149 'tablet_default' => [
150 'unit' => '%',
151 ],
152 'mobile_default' => [
153 'unit' => '%',
154 ],
155 'range' => [
156 '%' => [
157 'min' => 5,
158 'max' => 100,
159 ],
160 'px' => [
161 'min' => 0,
162 'max' => 1000,
163 ],
164 ],
165 'selectors' => [
166 '{{WRAPPER}} .woocommerce-product-gallery' => 'width: {{SIZE}}{{UNIT}};',
167 ],
168 ]
169 );
170
171 $this->add_responsive_control(
172 'gallery_max_width',
173 [
174 'label' => __( 'Max Width (%)', 'sellkit' ),
175 'type' => 'slider',
176 'size_units' => [ '%' ],
177 'render_type' => 'template',
178 'range' => [
179 '%' => [
180 'min' => 0,
181 'max' => 100,
182 ],
183 ],
184 'default' => [
185 'unit' => '%',
186 ],
187 'tablet_default' => [
188 'unit' => '%',
189 ],
190 'mobile_default' => [
191 'unit' => '%',
192 ],
193 'selectors' => [
194 '{{WRAPPER}} .woocommerce-product-gallery' => 'max-width: {{SIZE}}{{UNIT}};',
195 ],
196 ]
197 );
198
199 $this->add_control(
200 'thumbanil_heading',
201 [
202 'label' => __( 'Thumbnail', 'sellkit' ),
203 'type' => 'heading',
204 'separator' => 'before',
205 'condition' => [
206 'slider_switch' => 'yes',
207 ],
208 ]
209 );
210
211 $this->add_control(
212 'thumbnail_border_type',
213 [
214 'label' => __( 'Border Type', 'sellkit' ),
215 'type' => 'select',
216 'render_type' => 'template',
217 'options' => [
218 '' => __( 'None', 'sellkit' ),
219 'solid' => __( 'Solid', 'sellkit' ),
220 'double' => __( 'Double', 'sellkit' ),
221 'dotted' => __( 'Dotted', 'sellkit' ),
222 'dashed' => __( 'Dashed', 'sellkit' ),
223 'groove' => __( 'Groove', 'sellkit' ),
224 ],
225 'selectors' => [
226 '{{WRAPPER}} .flex-control-nav li' => 'border-style: {{VALUE}} !important;',
227 ],
228 'condition' => [
229 'slider_switch' => 'yes',
230 ],
231 ]
232 );
233
234 $this->add_control(
235 'thumbnail_border_color',
236 [
237 'label' => __( 'Border Color', 'sellkit' ),
238 'type' => 'color',
239 'selectors' => [
240 '{{WRAPPER}} .flex-control-nav li' => 'border-color: {{VALUE}} !important;',
241 ],
242 'condition' => [
243 'thumbnail_border_type!' => '',
244 'slider_switch' => 'yes',
245 ],
246 ]
247 );
248
249 $this->add_responsive_control(
250 'thumbnail_border_width',
251 [
252 'label' => __( 'Border Width', 'sellkit' ),
253 'type' => 'slider',
254 'size_units' => [ 'px' ],
255 'default' => [
256 'size' => 1,
257 ],
258 'range' => [
259 'px' => [
260 'min' => 0,
261 'max' => 100,
262 ],
263 ],
264 'selectors' => [
265 '{{WRAPPER}} .flex-control-nav li' => 'border-width: {{SIZE}}{{UNIT}} !important;',
266 ],
267 'condition' => [
268 'thumbnail_border_type!' => '',
269 'slider_switch' => 'yes',
270 ],
271 ]
272 );
273
274 $this->add_responsive_control(
275 'thumbnail_border_radius',
276 [
277 'label' => __( 'Border Radius', 'sellkit' ),
278 'type' => 'dimensions',
279 'frontend_available' => true,
280 'size_units' => [ 'px', '%' ],
281 'default' => [
282 'unit' => 'px',
283 ],
284 'selectors' => [
285 '{{WRAPPER}} .flex-control-nav li' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}}; ',
286 ],
287 'condition' => [
288 'slider_switch' => 'yes',
289 ],
290 ]
291 );
292
293 $this->add_control(
294 'thumbnail_spacing',
295 [
296 'label' => __( 'Spacing', 'sellkit' ),
297 'type' => 'slider',
298 'default' => [
299 'size' => 10,
300 ],
301 'description' => __( 'Between main image and gallery slider(If slider available)', 'jupitrex-core' ),
302 'selectors' => [
303 '{{WRAPPER}} .flex-control-nav li' => 'margin-right: {{SIZE}}{{UNIT}} !important; margin-bottom: {{SIZE}}{{UNIT}} !important;',
304 ],
305 'condition' => [
306 'slider_switch' => 'yes',
307 ],
308 ]
309 );
310
311 $this->end_controls_section();
312 }
313
314 /**
315 * Content section controls.
316 *
317 * @since 1.1.0
318 */
319 private function register_content_box_controls() {
320 $this->start_controls_section(
321 'content',
322 [
323 'label' => __( 'Content', 'sellkit' ),
324 'tab' => 'content',
325 ]
326 );
327
328 $this->add_control(
329 'slider_switch',
330 [
331 'label' => __( 'Enable Slider', 'sellkit' ),
332 'type' => 'switcher',
333 'default' => 'yes',
334 'description' => __( 'Note: Slider is only show if gallery images are available.', 'sellkit' ),
335 'yes' => __( 'Yes', 'sellkit' ),
336 'no' => __( 'No', 'sellkit' ),
337 ]
338 );
339
340 $this->add_responsive_control(
341 'content_align',
342 [
343 'label' => __( 'Alignment', 'sellkit' ),
344 'type' => 'choose',
345 'default' => 'start',
346 'options' => [
347 'flex-start' => [
348 'title' => __( 'Left', 'sellkit' ),
349 'icon' => 'fa fa-align-left',
350 ],
351 'center' => [
352 'title' => __( 'Center', 'sellkit' ),
353 'icon' => 'fa fa-align-center',
354 ],
355 'flex-end' => [
356 'title' => __( 'Right', 'sellkit' ),
357 'icon' => 'fa fa-align-right',
358 ],
359 ],
360 'selectors' => [
361 '{{WRAPPER}} .product' => 'justify-content: {{VALUE}};',
362 ],
363 ]
364 );
365
366 $this->end_controls_section();
367 }
368
369 protected function render() {
370 global $product;
371
372 $settings = $this->get_settings_for_display();
373 $product = $this->get_product_object();
374 $slider_class = 'yes' === $settings['slider_switch'] ? 'product-images-is-slider' : '';
375
376 if ( empty( $product ) ) {
377 return;
378 }
379
380 echo "<div class='sellkit-product-image-widget product $slider_class' >";
381
382 if ( 'yes' !== $settings['slider_switch'] ) {
383 $product->set_gallery_image_ids( [] );
384 }
385
386 wc_get_template( 'single-product/product-image.php' );
387
388 echo '</div>';
389 }
390 }
391