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