product-image.php
753 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Elementor; |
| 4 | |
| 5 | use ShopEngine\Widgets\Products; |
| 6 | |
| 7 | defined('ABSPATH') || exit; |
| 8 | |
| 9 | class ShopEngine_Product_Image extends \ShopEngine\Base\Widget { |
| 10 | |
| 11 | public function config() { |
| 12 | return new ShopEngine_Product_Image_Config(); |
| 13 | } |
| 14 | |
| 15 | |
| 16 | protected function register_controls() { |
| 17 | |
| 18 | /* |
| 19 | -------------------------- |
| 20 | settings content tab |
| 21 | -------------------------- |
| 22 | */ |
| 23 | |
| 24 | $this->start_controls_section( |
| 25 | 'shopengine_widget_settings', |
| 26 | [ |
| 27 | 'label' => esc_html__('Settings', 'shopengine'), |
| 28 | 'tab' => Controls_Manager::TAB_CONTENT, |
| 29 | ] |
| 30 | ); |
| 31 | |
| 32 | $this->add_control( |
| 33 | 'shopengine_image_lightbox_icon_heading', |
| 34 | [ |
| 35 | 'label' => esc_html__('Product Lightbox', 'shopengine'), |
| 36 | 'type' => Controls_Manager::HEADING, |
| 37 | 'separator' => 'before', |
| 38 | ] |
| 39 | ); |
| 40 | |
| 41 | $this->add_control( |
| 42 | 'shopengine_image_lightbox_icon', |
| 43 | [ |
| 44 | 'label' => esc_html__('Icon', 'shopengine'), |
| 45 | 'type' => Controls_Manager::ICONS, |
| 46 | 'fa4compatibility' => 'icon', |
| 47 | 'default' => [ |
| 48 | 'value' => 'fas fa-expand-alt', |
| 49 | 'library' => 'fa-solid', |
| 50 | ], |
| 51 | ] |
| 52 | ); |
| 53 | |
| 54 | $this->add_control( |
| 55 | 'shopengine_sale_flash_status_heading', |
| 56 | [ |
| 57 | 'label' => esc_html__('Flash Sale Badge', 'shopengine'), |
| 58 | 'type' => Controls_Manager::HEADING, |
| 59 | 'separator' => 'before', |
| 60 | ] |
| 61 | ); |
| 62 | |
| 63 | $this->add_control( |
| 64 | 'shopengine_sale_flash_status', |
| 65 | [ |
| 66 | 'label' => esc_html__('Show Badge?', 'shopengine'), |
| 67 | 'type' => Controls_Manager::SWITCHER, |
| 68 | 'label_on' => esc_html__('Show', 'shopengine'), |
| 69 | 'label_off' => esc_html__('Hide', 'shopengine'), |
| 70 | 'render_type' => 'template', |
| 71 | 'return_value' => 'yes', |
| 72 | 'default' => 'yes', |
| 73 | ] |
| 74 | ); |
| 75 | |
| 76 | $this->end_controls_section(); // end ./settings content tab |
| 77 | |
| 78 | /* |
| 79 | -------------------------- |
| 80 | product image style |
| 81 | -------------------------- |
| 82 | */ |
| 83 | |
| 84 | $this->start_controls_section( |
| 85 | 'shopengine_image_style', |
| 86 | [ |
| 87 | 'label' => esc_html__('Image', 'shopengine'), |
| 88 | 'tab' => Controls_Manager::TAB_STYLE, |
| 89 | ] |
| 90 | ); |
| 91 | |
| 92 | $this->add_control( |
| 93 | 'shopengine_image_border_radius', |
| 94 | [ |
| 95 | 'label' => esc_html__('Border Radius', 'shopengine'), |
| 96 | 'type' => Controls_Manager::SLIDER, |
| 97 | 'size_units' => ['px', '%'], |
| 98 | 'range' => [ |
| 99 | 'px' => [ |
| 100 | 'min' => 0, |
| 101 | 'max' => 100, |
| 102 | 'step' => 1, |
| 103 | ], |
| 104 | '%' => [ |
| 105 | 'min' => 0, |
| 106 | 'max' => 100, |
| 107 | 'step' => 1, |
| 108 | ], |
| 109 | ], |
| 110 | 'selectors' => [ |
| 111 | '.woocommerce {{WRAPPER}} .shopengine-product-image .woocommerce-product-gallery__trigger + .woocommerce-product-gallery__wrapper, |
| 112 | .woocommerce {{WRAPPER}} .shopengine-product-image .img-thumbnail, |
| 113 | .woocommerce {{WRAPPER}} .shopengine-product-image .flex-viewport' => 'border-radius: {{SIZE}}{{UNIT}};', |
| 114 | ], |
| 115 | ] |
| 116 | ); |
| 117 | |
| 118 | $this->add_control( |
| 119 | 'shopengine_heading_gallery_thumbs_style', |
| 120 | [ |
| 121 | 'label' => esc_html__('Gallery Thumbnails', 'shopengine'), |
| 122 | 'type' => Controls_Manager::HEADING, |
| 123 | 'separator' => 'before', |
| 124 | ] |
| 125 | ); |
| 126 | |
| 127 | $this->add_responsive_control( |
| 128 | 'shopengine_gallery_thumbs_column', |
| 129 | [ |
| 130 | 'label' => esc_html__('Column', 'shopengine'), |
| 131 | 'type' => Controls_Manager::NUMBER, |
| 132 | 'size_units' => ['px'], |
| 133 | 'range' => [ |
| 134 | 'px' => [ |
| 135 | 'min' => 0, |
| 136 | 'max' => 12, |
| 137 | 'step' => 1, |
| 138 | ], |
| 139 | ], |
| 140 | 'default' => 4, |
| 141 | 'selectors' => [ |
| 142 | '{{WRAPPER}} .shopengine-product-image .product-thumbs-slider' => 'grid-template-columns: repeat({{SIZE}}, 1fr)', |
| 143 | '{{WRAPPER}} .shopengine-product-image .product-thumbs-slider .owl-stage' => 'grid-template-columns: repeat({{SIZE}}, 1fr)', |
| 144 | ], |
| 145 | ] |
| 146 | ); |
| 147 | |
| 148 | $this->add_group_control( |
| 149 | Group_Control_Border::get_type(), |
| 150 | [ |
| 151 | 'name' => 'shopengine_thumbs_border', |
| 152 | 'selector' => '.woocommerce {{WRAPPER}} .shopengine-product-image .flex-control-thumbs img, |
| 153 | .woocommerce {{WRAPPER}} .shopengine-product-image .product-thumbs-slider .img-thumbnail, |
| 154 | .woocommerce {{WRAPPER}} .woocommerce-product-gallery #product-thumbnails-carousel .slick-slide:hover img, |
| 155 | .woocommerce {{WRAPPER}} .woocommerce-product-gallery #product-thumbnails-carousel .slick-current img', |
| 156 | 'fields_options' => [ |
| 157 | 'color' => [ |
| 158 | 'label' => esc_html__('Border Color', 'shopengine'), |
| 159 | 'alpha' => false, |
| 160 | ], |
| 161 | |
| 162 | ], |
| 163 | ] |
| 164 | ); |
| 165 | |
| 166 | $this->add_control( |
| 167 | 'shopengine_thumbs_border_radius', |
| 168 | [ |
| 169 | 'label' => esc_html__('Border Radius (px)', 'shopengine'), |
| 170 | 'type' => Controls_Manager::SLIDER, |
| 171 | 'size_units' => ['px', '%'], |
| 172 | 'range' => [ |
| 173 | 'px' => [ |
| 174 | 'min' => 0, |
| 175 | 'max' => 100, |
| 176 | 'step' => 1, |
| 177 | ], |
| 178 | '%' => [ |
| 179 | 'min' => 0, |
| 180 | 'max' => 100, |
| 181 | 'step' => 1, |
| 182 | ], |
| 183 | ], |
| 184 | 'selectors' => [ |
| 185 | '.woocommerce {{WRAPPER}} .shopengine-product-image .flex-control-thumbs img, |
| 186 | .woocommerce {{WRAPPER}} .shopengine-product-image .product-thumbs-slider .img-thumbnail, |
| 187 | .woocommerce-product-gallery #product-thumbnails-carousel .slick-slide:hover img, |
| 188 | .woocommerce-product-gallery #product-thumbnails-carousel .slick-current img' |
| 189 | => 'border-radius: {{SIZE}}{{UNIT}}', |
| 190 | ], |
| 191 | ] |
| 192 | ); |
| 193 | |
| 194 | $this->add_control( |
| 195 | 'shopengine_gallery_thumbs_row_gap', |
| 196 | [ |
| 197 | 'label' => esc_html__('Row Gap (px)', 'shopengine'), |
| 198 | 'type' => Controls_Manager::SLIDER, |
| 199 | 'size_units' => ['px'], |
| 200 | 'range' => [ |
| 201 | 'px' => [ |
| 202 | 'min' => 0, |
| 203 | 'max' => 100, |
| 204 | 'step' => 1, |
| 205 | ], |
| 206 | ], |
| 207 | 'default' => [ |
| 208 | 'unit' => 'px', |
| 209 | 'size' => 15, |
| 210 | ], |
| 211 | 'selectors' => [ |
| 212 | '{{WRAPPER}} .shopengine-product-image .flex-control-thumbs' => 'row-gap: {{SIZE}}{{UNIT}};', |
| 213 | '{{WRAPPER}} .shopengine-product-image .product-thumbs-slider:not( .owl-loaded )' => 'row-gap: {{SIZE}}{{UNIT}};', |
| 214 | '{{WRAPPER}} .shopengine-product-image .product-thumbs-slider .owl-stage' => 'row-gap: {{SIZE}}{{UNIT}};', |
| 215 | ], |
| 216 | ] |
| 217 | ); |
| 218 | |
| 219 | $this->add_control( |
| 220 | 'shopengine_gallery_thumbs_column_gap', |
| 221 | [ |
| 222 | 'label' => esc_html__('Column Gap (px)', 'shopengine'), |
| 223 | 'type' => Controls_Manager::SLIDER, |
| 224 | 'size_units' => ['px'], |
| 225 | 'range' => [ |
| 226 | 'px' => [ |
| 227 | 'min' => 0, |
| 228 | 'max' => 100, |
| 229 | 'step' => 1, |
| 230 | ], |
| 231 | ], |
| 232 | 'default' => [ |
| 233 | 'unit' => 'px', |
| 234 | 'size' => 20, |
| 235 | ], |
| 236 | 'selectors' => [ |
| 237 | '{{WRAPPER}} .shopengine-product-image .flex-control-thumbs' => 'column-gap: {{SIZE}}{{UNIT}}', |
| 238 | '{{WRAPPER}} .shopengine-product-image .product-thumbs-slider:not( .owl-loaded )' => 'column-gap: {{SIZE}}{{UNIT}};', |
| 239 | '{{WRAPPER}} .shopengine-product-image .product-thumbs-slider .owl-stage' => 'column-gap: {{SIZE}}{{UNIT}};', |
| 240 | ], |
| 241 | ] |
| 242 | ); |
| 243 | |
| 244 | $this->add_responsive_control( |
| 245 | 'shopengine_thumbs_margin', |
| 246 | [ |
| 247 | 'label' => __('Margin (px)', 'shopengine'), |
| 248 | 'type' => Controls_Manager::DIMENSIONS, |
| 249 | 'default' => [ |
| 250 | 'top' => '20', |
| 251 | 'right' => '0', |
| 252 | 'bottom' => '0', |
| 253 | 'left' => '0', |
| 254 | 'unit' => 'px', |
| 255 | 'isLinked' => false, |
| 256 | ], |
| 257 | 'size_units' => ['px'], |
| 258 | 'selectors' => [ |
| 259 | '{{WRAPPER}} .shopengine-product-image .flex-control-thumbs' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 260 | '{{WRAPPER}} .shopengine-product-image .product-thumbs-slider' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 261 | ], |
| 262 | 'separator' => 'before', |
| 263 | ] |
| 264 | ); |
| 265 | |
| 266 | $this->end_controls_section(); // end ./ product image style |
| 267 | |
| 268 | /* |
| 269 | -------------------------- |
| 270 | lightbox zoom icon |
| 271 | -------------------------- |
| 272 | */ |
| 273 | |
| 274 | $this->start_controls_section( |
| 275 | 'shopengine_lightbox_icon_style', |
| 276 | [ |
| 277 | 'label' => esc_html__('Lightbox Zoom Icon', 'shopengine'), |
| 278 | 'tab' => Controls_Manager::TAB_STYLE, |
| 279 | ] |
| 280 | ); |
| 281 | |
| 282 | $this->add_control( |
| 283 | 'shopengine_lightbox_icon_color', |
| 284 | [ |
| 285 | 'label' => esc_html__('Icon Color', 'shopengine'), |
| 286 | 'type' => Controls_Manager::COLOR, |
| 287 | 'default' => '#101010', |
| 288 | 'alpha' => false, |
| 289 | 'selectors' => [ |
| 290 | '{{WRAPPER}} .shopengine-product-image .shopengine-product-image-toggle' => 'color: {{VALUE}}', |
| 291 | ], |
| 292 | ] |
| 293 | ); |
| 294 | |
| 295 | $this->add_control( |
| 296 | 'shopengine_lightbox_icon_background', |
| 297 | [ |
| 298 | 'label' => esc_html__('Icon Background Color', 'shopengine'), |
| 299 | 'type' => Controls_Manager::COLOR, |
| 300 | 'alpha' => false, |
| 301 | 'default' => '#ffffff', |
| 302 | 'selectors' => [ |
| 303 | '{{WRAPPER}} .shopengine-product-image .shopengine-product-image-toggle' => 'background-color: {{VALUE}}', |
| 304 | ], |
| 305 | ] |
| 306 | ); |
| 307 | |
| 308 | $this->add_control( |
| 309 | 'shopengine_lightbox_icon_size', |
| 310 | [ |
| 311 | 'label' => esc_html__('Size (px)', 'shopengine'), |
| 312 | 'type' => Controls_Manager::SLIDER, |
| 313 | 'size_units' => ['px'], |
| 314 | 'range' => [ |
| 315 | 'px' => [ |
| 316 | 'min' => 0, |
| 317 | 'max' => 100, |
| 318 | 'step' => 1, |
| 319 | ], |
| 320 | ], |
| 321 | 'default' => [ |
| 322 | 'unit' => 'px', |
| 323 | 'size' => 16, |
| 324 | ], |
| 325 | 'selectors' => [ |
| 326 | '{{WRAPPER}} .shopengine-product-image .shopengine-product-image-toggle' => 'font-size: {{SIZE}}{{UNIT}};', |
| 327 | ], |
| 328 | ] |
| 329 | ); |
| 330 | |
| 331 | $this->add_control( |
| 332 | 'shopengine_lightbox_icon_wrapper_size', |
| 333 | [ |
| 334 | 'label' => esc_html__('Wrapper Size (px)', 'shopengine'), |
| 335 | 'type' => Controls_Manager::SLIDER, |
| 336 | 'size_units' => ['px'], |
| 337 | 'range' => [ |
| 338 | 'px' => [ |
| 339 | 'min' => 0, |
| 340 | 'max' => 100, |
| 341 | 'step' => 1, |
| 342 | ], |
| 343 | ], |
| 344 | 'default' => [ |
| 345 | 'unit' => 'px', |
| 346 | 'size' => 46, |
| 347 | ], |
| 348 | 'selectors' => [ |
| 349 | '{{WRAPPER}} .shopengine-product-image .shopengine-product-image-toggle' => 'height: {{SIZE}}{{UNIT}}; width: {{SIZE}}{{UNIT}}', |
| 350 | ], |
| 351 | ] |
| 352 | ); |
| 353 | |
| 354 | $this->add_control( |
| 355 | 'shopengine_lightbox_icon_radius', |
| 356 | [ |
| 357 | 'label' => esc_html__('Border Radius (px)', 'shopengine'), |
| 358 | 'type' => Controls_Manager::SLIDER, |
| 359 | 'size_units' => ['px'], |
| 360 | 'range' => [ |
| 361 | 'px' => [ |
| 362 | 'min' => 0, |
| 363 | 'max' => 100, |
| 364 | 'step' => 5, |
| 365 | ], |
| 366 | ], |
| 367 | 'default' => [ |
| 368 | 'unit' => 'px', |
| 369 | 'size' => 100, |
| 370 | ], |
| 371 | 'selectors' => [ |
| 372 | '{{WRAPPER}} .shopengine-product-image .shopengine-product-image-toggle' => 'border-radius: {{SIZE}}{{UNIT}}', |
| 373 | ], |
| 374 | ] |
| 375 | ); |
| 376 | |
| 377 | $this->add_control( |
| 378 | 'shopengine_lightbox_icon_position', |
| 379 | [ |
| 380 | 'label' => esc_html__('Position', 'shopengine'), |
| 381 | 'type' => Controls_Manager::CHOOSE, |
| 382 | 'options' => [ |
| 383 | 'top-left' => [ |
| 384 | 'title' => esc_html__('Top Left', 'shopengine'), |
| 385 | 'icon' => 'eicon-h-align-left', |
| 386 | ], |
| 387 | 'top-right' => [ |
| 388 | 'title' => esc_html__('Top Right', 'shopengine'), |
| 389 | 'icon' => 'eicon-h-align-right', |
| 390 | ], |
| 391 | 'custom' => [ |
| 392 | 'title' => esc_html__('Custom', 'shopengine'), |
| 393 | 'icon' => 'eicon-settings', |
| 394 | ], |
| 395 | ], |
| 396 | 'default' => 'top-right', |
| 397 | 'toggle' => false, |
| 398 | 'separator' => 'before', |
| 399 | ] |
| 400 | ); |
| 401 | |
| 402 | $this->add_control( |
| 403 | 'shopengine_lightbox_icon_position_x_axis', |
| 404 | [ |
| 405 | 'label' => esc_html__('Badge Position (X axis)', 'shopengine'), |
| 406 | 'type' => Controls_Manager::SLIDER, |
| 407 | 'size_units' => ['px', '%'], |
| 408 | 'range' => [ |
| 409 | 'px' => [ |
| 410 | 'min' => 0, |
| 411 | 'max' => 1000, |
| 412 | 'step' => 1, |
| 413 | ], |
| 414 | '%' => [ |
| 415 | 'min' => 0, |
| 416 | 'max' => 100, |
| 417 | ], |
| 418 | ], |
| 419 | 'default' => [ |
| 420 | 'unit' => 'px', |
| 421 | 'size' => 20, |
| 422 | ], |
| 423 | 'selectors' => [ |
| 424 | '{{WRAPPER}} .shopengine-product-image .shopengine-product-image-toggle' => 'left: {{SIZE}}{{UNIT}};', |
| 425 | ], |
| 426 | 'condition' => [ |
| 427 | 'shopengine_lightbox_icon_position' => 'custom', |
| 428 | ], |
| 429 | ] |
| 430 | ); |
| 431 | |
| 432 | $this->add_control( |
| 433 | 'shopengine_lightbox_icon_position_y_axis', |
| 434 | [ |
| 435 | 'label' => esc_html__('Badge Position (Y axis)', 'shopengine'), |
| 436 | 'type' => Controls_Manager::SLIDER, |
| 437 | 'size_units' => ['px', '%'], |
| 438 | 'range' => [ |
| 439 | 'px' => [ |
| 440 | 'min' => 0, |
| 441 | 'max' => 1000, |
| 442 | 'step' => 1, |
| 443 | ], |
| 444 | '%' => [ |
| 445 | 'min' => 0, |
| 446 | 'max' => 100, |
| 447 | ], |
| 448 | ], |
| 449 | 'default' => [ |
| 450 | 'unit' => 'px', |
| 451 | 'size' => 20, |
| 452 | ], |
| 453 | 'selectors' => [ |
| 454 | '{{WRAPPER}} .shopengine-product-image .shopengine-product-image-toggle' => 'top: {{SIZE}}{{UNIT}};', |
| 455 | ], |
| 456 | 'condition' => [ |
| 457 | 'shopengine_lightbox_icon_position' => 'custom', |
| 458 | ], |
| 459 | ] |
| 460 | ); |
| 461 | |
| 462 | $this->end_controls_section(); // end ./ lightbox zoom icon |
| 463 | |
| 464 | /* |
| 465 | -------------------------- |
| 466 | Flash sale badge style |
| 467 | -------------------------- |
| 468 | */ |
| 469 | $this->start_controls_section( |
| 470 | 'shopengine_flash_sale_badge_style', |
| 471 | [ |
| 472 | 'label' => esc_html__('Flash Sale Badge', 'shopengine'), |
| 473 | 'tab' => Controls_Manager::TAB_STYLE, |
| 474 | 'condition' => [ |
| 475 | 'shopengine_sale_flash_status' => 'yes', |
| 476 | ], |
| 477 | ] |
| 478 | ); |
| 479 | |
| 480 | $this->add_control( |
| 481 | 'shopengine_flash_sale_color', |
| 482 | [ |
| 483 | 'label' => esc_html__('Color', 'shopengine'), |
| 484 | 'type' => Controls_Manager::COLOR, |
| 485 | 'default' => '#ffffff', |
| 486 | 'alpha' => false, |
| 487 | 'selectors' => [ |
| 488 | '{{WRAPPER}} .shopengine-product-image .onsale' => 'color: {{VALUE}}', |
| 489 | ], |
| 490 | ] |
| 491 | ); |
| 492 | |
| 493 | $this->add_control( |
| 494 | 'shopengine_flash_sale_background', |
| 495 | [ |
| 496 | 'label' => esc_html__('Background Color', 'shopengine'), |
| 497 | 'type' => Controls_Manager::COLOR, |
| 498 | 'default' => '#8fa775', |
| 499 | 'alpha' => false, |
| 500 | 'selectors' => [ |
| 501 | '{{WRAPPER}} .shopengine-product-image .onsale' => 'background-color: {{VALUE}}', |
| 502 | ], |
| 503 | ] |
| 504 | ); |
| 505 | |
| 506 | $this->add_group_control( |
| 507 | Group_Control_Typography::get_type(), |
| 508 | [ |
| 509 | 'name' => 'shopengine_onsale_primary', |
| 510 | 'label' => esc_html__('Typography', 'shopengine'), |
| 511 | 'selector' => '{{WRAPPER}} .shopengine-product-image .onsale', |
| 512 | 'exclude' => ['letter_spacing', 'text_decoration', 'font_weight', 'font_style'], |
| 513 | |
| 514 | 'fields_options' => [ |
| 515 | 'typography' => [ |
| 516 | 'default' => 'custom', |
| 517 | ], |
| 518 | 'font_size' => [ |
| 519 | 'label' => esc_html__('Font Size (px)', 'shopengine'), |
| 520 | 'default' => [ |
| 521 | 'size' => '16', |
| 522 | 'unit' => 'px', |
| 523 | ], |
| 524 | 'size_units' => ['px'], |
| 525 | ], |
| 526 | 'line_height' => [ |
| 527 | 'label' => esc_html__('Line-height (px)', 'shopengine'), |
| 528 | 'default' => [ |
| 529 | 'size' => '20', |
| 530 | 'unit' => 'px', |
| 531 | ], |
| 532 | 'size_units' => ['px'], |
| 533 | ], |
| 534 | ], |
| 535 | ] |
| 536 | ); |
| 537 | |
| 538 | $this->add_control( |
| 539 | 'shopengine_flash_sale_height_width_status', |
| 540 | [ |
| 541 | 'label' => esc_html__('Fixed Height Width', 'shopengine'), |
| 542 | 'type' => Controls_Manager::SWITCHER, |
| 543 | 'label_on' => esc_html__('Show', 'shopengine'), |
| 544 | 'label_off' => esc_html__('Hide', 'shopengine'), |
| 545 | 'render_type' => 'template', |
| 546 | 'return_value' => 'yes', |
| 547 | 'default' => 'yes', |
| 548 | ] |
| 549 | ); |
| 550 | |
| 551 | $this->add_control( |
| 552 | 'shopengine_flash_sale_height', |
| 553 | [ |
| 554 | 'label' => esc_html__('Height (px)', 'shopengine'), |
| 555 | 'type' => Controls_Manager::SLIDER, |
| 556 | 'size_units' => ['px'], |
| 557 | 'range' => [ |
| 558 | 'px' => [ |
| 559 | 'min' => 0, |
| 560 | 'max' => 200, |
| 561 | 'step' => 1, |
| 562 | ], |
| 563 | ], |
| 564 | 'default' => [ |
| 565 | 'unit' => 'px', |
| 566 | 'size' => 70, |
| 567 | ], |
| 568 | 'selectors' => [ |
| 569 | '{{WRAPPER}} .shopengine-product-image .onsale' => 'height: {{SIZE}}{{UNIT}};', |
| 570 | ], |
| 571 | 'condition' => [ |
| 572 | 'shopengine_flash_sale_height_width_status' => 'yes', |
| 573 | ], |
| 574 | ] |
| 575 | ); |
| 576 | |
| 577 | $this->add_control( |
| 578 | 'shopengine_flash_sale_width', |
| 579 | [ |
| 580 | 'label' => esc_html__('Width (px)', 'shopengine'), |
| 581 | 'type' => Controls_Manager::SLIDER, |
| 582 | 'size_units' => ['px'], |
| 583 | 'range' => [ |
| 584 | 'px' => [ |
| 585 | 'min' => 0, |
| 586 | 'max' => 200, |
| 587 | 'step' => 1, |
| 588 | ], |
| 589 | ], |
| 590 | 'default' => [ |
| 591 | 'unit' => 'px', |
| 592 | 'size' => 70, |
| 593 | ], |
| 594 | 'selectors' => [ |
| 595 | '{{WRAPPER}} .shopengine-product-image .onsale' => 'width: {{SIZE}}{{UNIT}}', |
| 596 | ], |
| 597 | 'condition' => [ |
| 598 | 'shopengine_flash_sale_height_width_status' => 'yes', |
| 599 | ], |
| 600 | ] |
| 601 | ); |
| 602 | |
| 603 | $this->add_control( |
| 604 | 'shopengine_flash_sale_radius', |
| 605 | [ |
| 606 | 'label' => esc_html__('Border Radius (px)', 'shopengine'), |
| 607 | 'type' => Controls_Manager::SLIDER, |
| 608 | 'size_units' => ['px'], |
| 609 | 'range' => [ |
| 610 | 'px' => [ |
| 611 | 'min' => 0, |
| 612 | 'max' => 100, |
| 613 | 'step' => 1, |
| 614 | ], |
| 615 | ], |
| 616 | 'default' => [ |
| 617 | 'unit' => 'px', |
| 618 | 'size' => 70, |
| 619 | ], |
| 620 | 'selectors' => [ |
| 621 | '{{WRAPPER}} .shopengine-product-image .onsale' => 'border-radius: {{SIZE}}{{UNIT}}', |
| 622 | ], |
| 623 | ] |
| 624 | ); |
| 625 | |
| 626 | $this->add_control( |
| 627 | 'shopengine_flash_sale_position', |
| 628 | [ |
| 629 | 'label' => esc_html__('Position', 'shopengine'), |
| 630 | 'type' => Controls_Manager::CHOOSE, |
| 631 | 'options' => [ |
| 632 | 'top-left' => [ |
| 633 | 'title' => esc_html__('Top Left', 'shopengine'), |
| 634 | 'icon' => 'eicon-h-align-left', |
| 635 | ], |
| 636 | 'top-right' => [ |
| 637 | 'title' => esc_html__('Top Right', 'shopengine'), |
| 638 | 'icon' => 'eicon-h-align-right', |
| 639 | ], |
| 640 | 'custom' => [ |
| 641 | 'title' => esc_html__('Custom', 'shopengine'), |
| 642 | 'icon' => 'eicon-settings', |
| 643 | ], |
| 644 | ], |
| 645 | 'default' => 'top-left', |
| 646 | 'toggle' => false, |
| 647 | 'separator' => 'before', |
| 648 | ] |
| 649 | ); |
| 650 | |
| 651 | $this->add_control( |
| 652 | 'shopengine_flash_sale_position_x_axis', |
| 653 | [ |
| 654 | 'label' => esc_html__('Badge Position (X axis)', 'shopengine'), |
| 655 | 'type' => Controls_Manager::SLIDER, |
| 656 | 'size_units' => ['px', '%'], |
| 657 | 'range' => [ |
| 658 | 'px' => [ |
| 659 | 'min' => 0, |
| 660 | 'max' => 1000, |
| 661 | 'step' => 1, |
| 662 | ], |
| 663 | '%' => [ |
| 664 | 'min' => 0, |
| 665 | 'max' => 100, |
| 666 | ], |
| 667 | ], |
| 668 | 'default' => [ |
| 669 | 'unit' => 'px', |
| 670 | 'size' => 20, |
| 671 | ], |
| 672 | 'selectors' => [ |
| 673 | '{{WRAPPER}} .shopengine-product-image .onsale' => 'left: {{SIZE}}{{UNIT}};', |
| 674 | ], |
| 675 | 'condition' => [ |
| 676 | 'shopengine_flash_sale_position' => 'custom', |
| 677 | ], |
| 678 | ] |
| 679 | ); |
| 680 | |
| 681 | $this->add_control( |
| 682 | 'shopengine_flash_sale_position_y_axis', |
| 683 | [ |
| 684 | 'label' => esc_html__('Badge Position (Y axis)', 'shopengine'), |
| 685 | 'type' => Controls_Manager::SLIDER, |
| 686 | 'size_units' => ['px', '%'], |
| 687 | 'range' => [ |
| 688 | 'px' => [ |
| 689 | 'min' => 0, |
| 690 | 'max' => 1000, |
| 691 | 'step' => 1, |
| 692 | ], |
| 693 | '%' => [ |
| 694 | 'min' => 0, |
| 695 | 'max' => 100, |
| 696 | ], |
| 697 | ], |
| 698 | 'default' => [ |
| 699 | 'unit' => 'px', |
| 700 | 'size' => 20, |
| 701 | ], |
| 702 | 'selectors' => [ |
| 703 | '{{WRAPPER}} .shopengine-product-image .onsale' => 'top: {{SIZE}}{{UNIT}};', |
| 704 | ], |
| 705 | 'condition' => [ |
| 706 | 'shopengine_flash_sale_position' => 'custom', |
| 707 | ], |
| 708 | ] |
| 709 | ); |
| 710 | |
| 711 | $this->end_controls_section(); |
| 712 | |
| 713 | |
| 714 | } |
| 715 | |
| 716 | /** |
| 717 | * Render widget output on the frontend. |
| 718 | * |
| 719 | * Written in PHP and used to generate the final HTML. |
| 720 | * |
| 721 | * @since 1.0.0 |
| 722 | * @access protected |
| 723 | */ |
| 724 | protected function screen() { |
| 725 | $settings = $this->get_settings_for_display(); |
| 726 | ?> |
| 727 | |
| 728 | <div class="shopengine-product-image"> |
| 729 | <a href="#" |
| 730 | class="shopengine-product-image-toggle position-<?php echo esc_attr($settings['shopengine_lightbox_icon_position']); ?>"> |
| 731 | <?php Icons_Manager::render_icon($settings['shopengine_image_lightbox_icon'], ['aria-hidden' => 'true']); ?> |
| 732 | </a> |
| 733 | <?php echo \ShopEngine\Utils\Helper::render($this->view_render($settings)); ?> |
| 734 | </div> |
| 735 | |
| 736 | <?php |
| 737 | } |
| 738 | |
| 739 | |
| 740 | protected function view_render($settings = []) { |
| 741 | |
| 742 | $product = wc_get_product(); |
| 743 | |
| 744 | if(empty($product)) { |
| 745 | $product = Products::instance()->get_product(''); |
| 746 | } |
| 747 | |
| 748 | $tpl = Products::instance()->get_widget_template('shopengine-product-image'); |
| 749 | |
| 750 | include $tpl; |
| 751 | } |
| 752 | } |
| 753 |