advanced-search.php
1122 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Elementor; |
| 4 | |
| 5 | defined('ABSPATH') || exit; |
| 6 | |
| 7 | use ShopEngine\Widgets\Products; |
| 8 | |
| 9 | class ShopEngine_Advanced_Search extends \ShopEngine\Base\Widget |
| 10 | { |
| 11 | |
| 12 | public function config() { |
| 13 | return new ShopEngine_Advanced_Search_Config(); |
| 14 | } |
| 15 | |
| 16 | protected function register_controls() { |
| 17 | |
| 18 | /* |
| 19 | ------------------------------ |
| 20 | General settings |
| 21 | ------------------------------ |
| 22 | */ |
| 23 | |
| 24 | $this->start_controls_section( |
| 25 | 'shopengine_advanced_search_general', |
| 26 | [ |
| 27 | 'label' => esc_html__('General', 'shopengine'), |
| 28 | 'tab' => Controls_Manager::TAB_CONTENT, |
| 29 | ] |
| 30 | ); |
| 31 | |
| 32 | $this->add_control( |
| 33 | 'shopengine_advanced_search_product_column', |
| 34 | [ |
| 35 | 'label' => esc_html__('Products Column', 'shopengine'), |
| 36 | 'type' => Controls_Manager::SELECT, |
| 37 | 'default' => '1', |
| 38 | 'tablet_default' => '2', |
| 39 | 'mobile_default' => '1', |
| 40 | 'options' => [ |
| 41 | '1' => 'Column 1', |
| 42 | '2' => 'Column 2', |
| 43 | '3' => 'Column 3', |
| 44 | '4' => 'Column 4', |
| 45 | '5' => 'Column 5', |
| 46 | ], |
| 47 | 'selectors' => [ |
| 48 | '{{WRAPPER}} .shopengine-advanced-search .shopengine-search-product' => 'grid-template-columns: repeat({{VALUE}}, 1fr);', |
| 49 | ], |
| 50 | ] |
| 51 | ); |
| 52 | |
| 53 | |
| 54 | $this->add_control( |
| 55 | 'shopengine_advanced_search_disable_category_btn', |
| 56 | [ |
| 57 | 'label' => esc_html__('Show category dropdown', 'shopengine'), |
| 58 | 'type' => Controls_Manager::SELECT, |
| 59 | 'default' => 'block', |
| 60 | 'tablet_default' => 'block', |
| 61 | 'mobile_default' => 'none', |
| 62 | 'options' => [ |
| 63 | 'block' => 'Show', |
| 64 | 'none' => 'Hide', |
| 65 | ], |
| 66 | 'selectors' => [ |
| 67 | '{{WRAPPER}} .shopengine-advanced-search .shopengine-category-select-wraper' => 'display: {{VALUE}};', |
| 68 | ], |
| 69 | 'separator' => 'before', |
| 70 | ] |
| 71 | ); |
| 72 | |
| 73 | $this->add_control( |
| 74 | 'shopengine_advanced_search_title_all', |
| 75 | [ |
| 76 | 'label' => esc_html__('Text for all categories', 'shopengine'), |
| 77 | 'description' => esc_html__('Add text for all categories options.', 'shopengine'), |
| 78 | 'type' => Controls_Manager::TEXT, |
| 79 | 'default' => 'All Categories', |
| 80 | 'condition' => [ |
| 81 | 'shopengine_advanced_search_disable_category_btn' => 'block', |
| 82 | ], |
| 83 | 'separator' => 'after', |
| 84 | ] |
| 85 | ); |
| 86 | $this->add_control( |
| 87 | 'shopengine_advanced_search_icon', |
| 88 | [ |
| 89 | 'label' => esc_html__('Search icon', 'shopengine'), |
| 90 | 'type' => Controls_Manager::ICONS, |
| 91 | 'default' => [ |
| 92 | 'value' => 'fas fa-search', |
| 93 | 'library' => 'fa-solid', |
| 94 | ], |
| 95 | ] |
| 96 | ); |
| 97 | |
| 98 | $this->add_control( |
| 99 | 'shopengine_advanced_add_search_text', |
| 100 | [ |
| 101 | 'label' => esc_html__('Add Search Text?', 'shopengine'), |
| 102 | 'type' => Controls_Manager::SWITCHER, |
| 103 | 'label_on' => esc_html__('Show', 'shopengine'), |
| 104 | 'label_off' => esc_html__('Hide', 'shopengine'), |
| 105 | 'return_value' => 'yes', |
| 106 | 'default' => 'no', |
| 107 | |
| 108 | ] |
| 109 | ); |
| 110 | |
| 111 | $this->add_control( |
| 112 | 'shopengine_is_image', |
| 113 | [ |
| 114 | 'label' => esc_html__('Hide Image from search?', 'shopengine'), |
| 115 | 'type' => Controls_Manager::SWITCHER, |
| 116 | 'label_on' => esc_html__('Show', 'shopengine'), |
| 117 | 'label_off' => esc_html__('Hide', 'shopengine'), |
| 118 | 'return_value' => 'no', |
| 119 | 'default' => 'no', |
| 120 | 'selectors' => [ |
| 121 | '{{WRAPPER}} .shopengine-advanced-search :is(.shopengine-search-product__item--image)' => 'display: none;', |
| 122 | ], |
| 123 | ] |
| 124 | ); |
| 125 | |
| 126 | $this->add_control( |
| 127 | 'shopengine_advanced_search_text', |
| 128 | [ |
| 129 | 'label' => esc_html__('Search Text', 'shopengine'), |
| 130 | 'type' => Controls_Manager::TEXT, |
| 131 | 'default' => '', |
| 132 | 'condition' => [ |
| 133 | 'shopengine_advanced_add_search_text' => 'yes', |
| 134 | ], |
| 135 | 'separator' => 'after', |
| 136 | 'description' => esc_html__('You can control the width from search icon style tab', 'shopengine'), |
| 137 | ] |
| 138 | ); |
| 139 | |
| 140 | $this->add_control( |
| 141 | 'shopengine_advanced_search_order', |
| 142 | [ |
| 143 | 'label' => __('Order Search Components?', 'shopengine'), |
| 144 | 'description' => esc_html__('This is advanced option to change the postion of the search components,', 'shopengine'), |
| 145 | 'type' => Controls_Manager::SWITCHER, |
| 146 | 'label_on' => __('Show', 'shopengine'), |
| 147 | 'label_off' => __('Hide', 'shopengine'), |
| 148 | 'return_value' => 'yes', |
| 149 | 'default' => 'no', |
| 150 | ] |
| 151 | ); |
| 152 | |
| 153 | $this->add_control( |
| 154 | 'shopengine_advanced_search_box_order', |
| 155 | [ |
| 156 | 'label' => __('Search Box', 'shopengine'), |
| 157 | 'type' => Controls_Manager::NUMBER, |
| 158 | 'default' => 1, |
| 159 | 'selectors' => [ |
| 160 | '{{WRAPPER}} .shopengine-advanced-search .search-input-group :is( button )' => 'order: {{VALUE}};', |
| 161 | ], |
| 162 | 'condition' => [ |
| 163 | 'shopengine_advanced_search_order' => 'yes', |
| 164 | ], |
| 165 | ] |
| 166 | ); |
| 167 | |
| 168 | $this->add_control( |
| 169 | 'shopengine_advanced_search_input_order', |
| 170 | [ |
| 171 | 'label' => __('Search Input', 'shopengine'), |
| 172 | 'type' => Controls_Manager::NUMBER, |
| 173 | 'default' => 2, |
| 174 | 'selectors' => [ |
| 175 | '{{WRAPPER}} .shopengine-advanced-search-input' => 'order: {{VALUE}};', |
| 176 | ], |
| 177 | 'condition' => [ |
| 178 | 'shopengine_advanced_search_order' => 'yes', |
| 179 | ], |
| 180 | ] |
| 181 | ); |
| 182 | |
| 183 | $this->add_control( |
| 184 | 'shopengine_advanced_search_category_order', |
| 185 | [ |
| 186 | 'label' => __('Category Selector', 'shopengine'), |
| 187 | 'type' => Controls_Manager::NUMBER, |
| 188 | 'default' => 2, |
| 189 | 'selectors' => [ |
| 190 | '{{WRAPPER}} .shopengine-category-select-wraper' => 'order: {{VALUE}};', |
| 191 | ], |
| 192 | 'condition' => [ |
| 193 | 'shopengine_advanced_search_order' => 'yes', |
| 194 | ], |
| 195 | ] |
| 196 | ); |
| 197 | |
| 198 | |
| 199 | $this->end_controls_section(); // end ./ general settings |
| 200 | |
| 201 | |
| 202 | /* |
| 203 | ------------------------------ |
| 204 | search bar style |
| 205 | ------------------------------ |
| 206 | */ |
| 207 | |
| 208 | $this->start_controls_section( |
| 209 | 'shopengine_advanced_search_search_bar', |
| 210 | [ |
| 211 | 'label' => esc_html__('Search form', 'shopengine'), |
| 212 | 'tab' => Controls_Manager::TAB_STYLE, |
| 213 | ] |
| 214 | ); |
| 215 | |
| 216 | |
| 217 | $this->add_control( |
| 218 | 'shopengine_advanced_search_search_bar_height', |
| 219 | [ |
| 220 | 'label' => esc_html__('Form Height', 'shopengine'), |
| 221 | 'type' => Controls_Manager::SLIDER, |
| 222 | 'size_units' => ['px'], |
| 223 | 'range' => [ |
| 224 | 'px' => [ |
| 225 | 'min' => 0, |
| 226 | 'max' => 300, |
| 227 | 'step' => 1, |
| 228 | ], |
| 229 | ], |
| 230 | 'default' => [ |
| 231 | 'unit' => 'px', |
| 232 | 'size' => 50, |
| 233 | ], |
| 234 | 'selectors' => [ |
| 235 | '{{WRAPPER}} .shopengine-advanced-search .search-input-group :is( button, input, select )' => 'height: {{SIZE}}{{UNIT}};', |
| 236 | ], |
| 237 | ] |
| 238 | ); |
| 239 | |
| 240 | $this->add_control( |
| 241 | 'shopengine_advanced_search_search_form_radius', |
| 242 | [ |
| 243 | 'label' => esc_html__('Form radius', 'shopengine'), |
| 244 | 'type' => Controls_Manager::DIMENSIONS, |
| 245 | 'size_units' => ['px'], |
| 246 | 'selectors' => [ |
| 247 | '{{WRAPPER}} .shopengine-advanced-search .search-input-group' => 'overflow:hidden; border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 248 | ], |
| 249 | ] |
| 250 | ); |
| 251 | $this->add_group_control( |
| 252 | Group_Control_Border::get_type(), |
| 253 | [ |
| 254 | 'name' => 'shopengine_advanced_search_searchbar_border', |
| 255 | 'label' => esc_html__('Border', 'shopengine'), |
| 256 | 'selector' => '{{WRAPPER}} .shopengine-advanced-search :is( .search-input-group )', |
| 257 | 'exclude' => ['color'], |
| 258 | 'fields_options' => [ |
| 259 | 'border_type' => [ |
| 260 | 'default' => 'yes', |
| 261 | ], |
| 262 | 'border' => [ |
| 263 | 'default' => 'solid', |
| 264 | 'responsive' => true, |
| 265 | ], |
| 266 | |
| 267 | 'width' => [ |
| 268 | 'label' => esc_html__('Border Width', 'shopengine'), |
| 269 | 'default' => [ |
| 270 | 'top' => '2', |
| 271 | 'right' => '2', |
| 272 | 'bottom' => '2', |
| 273 | 'left' => '2', |
| 274 | 'unit' => 'px', |
| 275 | ], |
| 276 | 'responsive' => true, |
| 277 | 'selectors' => [ |
| 278 | '{{WRAPPER}} .shopengine-advanced-search :is( .search-input-group )' => 'border-width: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}}; margin: -{{TOP}}{{UNIT}} 0 -{{BOTTOM}}{{UNIT}} -2px;', |
| 279 | ], |
| 280 | ], |
| 281 | |
| 282 | 'color' => [ |
| 283 | 'label' => esc_html__('Border Color', 'shopengine'), |
| 284 | 'alpha' => false, |
| 285 | 'default' => '#E6E6E6', |
| 286 | 'responsive' => false, |
| 287 | ], |
| 288 | |
| 289 | ], |
| 290 | ] |
| 291 | ); |
| 292 | |
| 293 | $this->add_control( |
| 294 | 'shopengine_advanced_search_input_clr', |
| 295 | [ |
| 296 | 'label' => esc_html__('Input box text color', 'shopengine'), |
| 297 | 'type' => Controls_Manager::COLOR, |
| 298 | 'default' => '#3E3E3E', |
| 299 | 'separator' => 'before', |
| 300 | 'alpha' => false, |
| 301 | 'selectors' => [ |
| 302 | '{{WRAPPER}} .shopengine-advanced-search .search-input-group input, |
| 303 | {{WRAPPER}} .shopengine-advanced-search .search-input-group input::placeholder' => 'color: {{VALUE}}', |
| 304 | ], |
| 305 | ] |
| 306 | ); |
| 307 | $this->add_control( |
| 308 | 'shopengine_advanced_search_input_bg_clr', |
| 309 | [ |
| 310 | 'label' => esc_html__('Input box background color', 'shopengine'), |
| 311 | 'type' => Controls_Manager::COLOR, |
| 312 | 'default' => '#ffffff', |
| 313 | 'alpha' => false, |
| 314 | 'selectors' => [ |
| 315 | '{{WRAPPER}} .shopengine-advanced-search .search-input-group :is( input )' => 'background: {{VALUE}}', |
| 316 | ], |
| 317 | ] |
| 318 | ); |
| 319 | |
| 320 | |
| 321 | $this->add_group_control( |
| 322 | Group_Control_Typography::get_type(), |
| 323 | [ |
| 324 | 'name' => 'shopengine_advanced_search_input_typography', |
| 325 | 'label' => esc_html__('Search box Typography', 'shopengine'), |
| 326 | 'selector' => '{{WRAPPER}} .shopengine-advanced-search .search-input-group :is( input, input::placeholder )', |
| 327 | 'exclude' => ['font_family', 'letter_spacing', 'text_decoration', 'font_style', 'line_height'], |
| 328 | 'fields_options' => [ |
| 329 | 'typography' => [ |
| 330 | 'default' => 'custom', |
| 331 | ], |
| 332 | 'font_weight' => [ |
| 333 | 'default' => '400', |
| 334 | ], |
| 335 | 'font_size' => [ |
| 336 | 'label' => esc_html__('Font Size (px)', 'shopengine'), |
| 337 | 'default' => [ |
| 338 | 'size' => '16', |
| 339 | 'unit' => 'px', |
| 340 | ], |
| 341 | 'responsive' => false, |
| 342 | 'size_units' => ['px'], |
| 343 | ], |
| 344 | ], |
| 345 | ] |
| 346 | ); |
| 347 | |
| 348 | |
| 349 | $this->end_controls_section(); // end ./ search bar style |
| 350 | |
| 351 | |
| 352 | /* |
| 353 | ------------------------------ |
| 354 | Search Icon style |
| 355 | ------------------------------ |
| 356 | */ |
| 357 | |
| 358 | $this->start_controls_section( |
| 359 | 'shopengine_advanced_search_search_icon_style', |
| 360 | [ |
| 361 | 'label' => esc_html__('Search Icon / Text style', 'shopengine'), |
| 362 | 'tab' => Controls_Manager::TAB_STYLE, |
| 363 | 'description' => esc_html__('You can control the width from search icon / text style option', 'shopengine'), |
| 364 | ] |
| 365 | ); |
| 366 | $this->add_control( |
| 367 | 'shopengine_advanced_search_btn_icon_clr', |
| 368 | [ |
| 369 | 'label' => esc_html__('Search button text color', 'shopengine'), |
| 370 | 'type' => Controls_Manager::COLOR, |
| 371 | 'default' => '#3E3E3E', |
| 372 | 'alpha' => false, |
| 373 | 'selectors' => [ |
| 374 | '{{WRAPPER}} .shopengine-advanced-search .search-input-group :is( button ) i, {{WRAPPER}} .shopengine-search-text' => 'color: {{VALUE}}', |
| 375 | ], |
| 376 | ] |
| 377 | ); |
| 378 | |
| 379 | $this->add_control( |
| 380 | 'shopengine_advanced_search_btn_bg_clr', |
| 381 | [ |
| 382 | 'label' => esc_html__('Search button background color', 'shopengine'), |
| 383 | 'type' => Controls_Manager::COLOR, |
| 384 | 'default' => '#E6E6E6', |
| 385 | 'alpha' => false, |
| 386 | 'selectors' => [ |
| 387 | '{{WRAPPER}} .shopengine-advanced-search :is( .search-input-group button, .search-input-group )' => 'background: {{VALUE}}; border-color:{{VALUE}}', |
| 388 | ], |
| 389 | ] |
| 390 | ); |
| 391 | |
| 392 | |
| 393 | $this->add_control( |
| 394 | 'shopengine_advanced_search_font_size', |
| 395 | [ |
| 396 | 'label' => esc_html__('Search Button Font Size', 'shopengine'), |
| 397 | 'type' => Controls_Manager::SLIDER, |
| 398 | 'size_units' => ['px'], |
| 399 | 'range' => [ |
| 400 | 'px' => [ |
| 401 | 'min' => 10, |
| 402 | 'max' => 40, |
| 403 | 'step' => 1, |
| 404 | ], |
| 405 | ], |
| 406 | 'selectors' => [ |
| 407 | '{{WRAPPER}} .shopengine-advanced-search .search-input-group :is( button ) i, {{WRAPPER}} .shopengine-search-text' => 'font-size: {{SIZE}}{{UNIT}};', |
| 408 | ], |
| 409 | ] |
| 410 | ); |
| 411 | |
| 412 | $this->add_control( |
| 413 | 'shopengine_advanced_search_search_button_width', |
| 414 | [ |
| 415 | 'label' => esc_html__('Search button width', 'shopengine'), |
| 416 | 'type' => Controls_Manager::SLIDER, |
| 417 | 'size_units' => ['px'], |
| 418 | 'range' => [ |
| 419 | 'px' => [ |
| 420 | 'min' => 40, |
| 421 | 'max' => 300, |
| 422 | 'step' => 1, |
| 423 | ], |
| 424 | ], |
| 425 | 'default' => [ |
| 426 | 'unit' => 'px', |
| 427 | 'size' => 50, |
| 428 | ], |
| 429 | 'selectors' => [ |
| 430 | '{{WRAPPER}} .shopengine-advanced-search .search-input-group :is( button )' => 'flex: 0 0 {{SIZE}}{{UNIT}};', |
| 431 | ], |
| 432 | ] |
| 433 | ); |
| 434 | |
| 435 | $this->add_control( |
| 436 | 'shopengine_advanced_search_text_gap', |
| 437 | [ |
| 438 | 'label' => esc_html__('Search Text Gap', 'shopengine'), |
| 439 | 'type' => Controls_Manager::SLIDER, |
| 440 | 'size_units' => ['px'], |
| 441 | 'selectors' => [ |
| 442 | '{{WRAPPER}} .shopengine-search-text' => 'margin-left: {{SIZE}}{{UNIT}};', |
| 443 | ], |
| 444 | 'condition' => [ |
| 445 | 'shopengine_advanced_add_search_text' => 'yes', |
| 446 | ], |
| 447 | ] |
| 448 | ); |
| 449 | |
| 450 | $this->end_controls_section(); // end ./ search icon style |
| 451 | |
| 452 | |
| 453 | /* |
| 454 | ------------------------------ |
| 455 | category style |
| 456 | ------------------------------ |
| 457 | */ |
| 458 | $this->start_controls_section( |
| 459 | 'shopengine_advanced_product_category_section', |
| 460 | [ |
| 461 | 'label' => esc_html__('Category Style', 'shopengine'), |
| 462 | 'tab' => Controls_Manager::TAB_STYLE, |
| 463 | ] |
| 464 | ); |
| 465 | |
| 466 | $this->add_control( |
| 467 | 'shopengine_advanced_product_category_clr', |
| 468 | [ |
| 469 | 'label' => esc_html__('Color', 'shopengine'), |
| 470 | 'type' => Controls_Manager::COLOR, |
| 471 | 'default' => '#3E3E3E', |
| 472 | 'alpha' => false, |
| 473 | 'selectors' => [ |
| 474 | '{{WRAPPER}} .shopengine-advanced-search .search-input-group :is( select )' => 'color: {{VALUE}}', |
| 475 | ], |
| 476 | ] |
| 477 | ); |
| 478 | |
| 479 | $this->add_control( |
| 480 | 'shopengine_advanced_product_category_bg', |
| 481 | [ |
| 482 | 'label' => esc_html__('Background Color', 'shopengine'), |
| 483 | 'type' => Controls_Manager::COLOR, |
| 484 | 'default' => '#ffffff', |
| 485 | 'alpha' => false, |
| 486 | 'selectors' => [ |
| 487 | '{{WRAPPER}} .shopengine-category-select-wraper' => 'background-color: {{VALUE}}', |
| 488 | '{{WRAPPER}} .shopengine-ele-nav-search-select' => 'background-color: transparent', |
| 489 | ], |
| 490 | ] |
| 491 | ); |
| 492 | |
| 493 | |
| 494 | $this->add_group_control( |
| 495 | Group_Control_Typography::get_type(), |
| 496 | [ |
| 497 | 'name' => 'shopengine_advanced_product_category_typography', |
| 498 | 'label' => esc_html__('Typography', 'shopengine'), |
| 499 | 'selector' => '{{WRAPPER}} .shopengine-advanced-search .search-input-group :is( select )', |
| 500 | 'exclude' => ['font_family', 'letter_spacing', 'text_decoration', 'font_style'], |
| 501 | |
| 502 | 'fields_options' => [ |
| 503 | 'typography' => [ |
| 504 | 'default' => 'custom', |
| 505 | ], |
| 506 | 'font_weight' => [ |
| 507 | 'default' => '500', |
| 508 | ], |
| 509 | 'font_size' => [ |
| 510 | 'label' => esc_html__('Font Size (px)', 'shopengine'), |
| 511 | 'default' => [ |
| 512 | 'size' => '15', |
| 513 | 'unit' => 'px', |
| 514 | ], |
| 515 | 'responsive' => false, |
| 516 | 'size_units' => ['px'], |
| 517 | ], |
| 518 | 'line_height' => [ |
| 519 | 'label' => esc_html__('Line-height (px)', 'shopengine'), |
| 520 | 'default' => [ |
| 521 | 'size' => '18', |
| 522 | 'unit' => 'px', |
| 523 | ], |
| 524 | 'responsive' => false, |
| 525 | 'size_units' => ['px'], |
| 526 | ], |
| 527 | ], |
| 528 | ] |
| 529 | ); |
| 530 | |
| 531 | $this->add_responsive_control( |
| 532 | 'shopengine_advanced_category_width', |
| 533 | [ |
| 534 | 'label' => esc_html__('Dropdown Category Width', 'shopengine'), |
| 535 | 'type' => Controls_Manager::SLIDER, |
| 536 | 'size_units' => ['px', '%'], |
| 537 | 'range' => [ |
| 538 | 'px' => [ |
| 539 | 'min' => 40, |
| 540 | 'max' => 300, |
| 541 | 'step' => 1, |
| 542 | ], |
| 543 | ], |
| 544 | 'selectors' => [ |
| 545 | '{{WRAPPER}} .shopengine-ele-nav-search-select' => 'width: {{SIZE}}{{UNIT}};', |
| 546 | ], |
| 547 | 'condition' => [ |
| 548 | 'shopengine_advanced_search_disable_category_btn' => 'block', |
| 549 | ], |
| 550 | ] |
| 551 | ); |
| 552 | |
| 553 | $this->add_responsive_control( |
| 554 | 'shopengine_advanced_separator_position', |
| 555 | [ |
| 556 | 'label' => esc_html__('Separator Position', 'shopengine'), |
| 557 | 'type' => Controls_Manager::CHOOSE, |
| 558 | 'default' => '0', |
| 559 | 'options' => [ |
| 560 | 'left' => [ |
| 561 | 'title' => esc_html__('Left', 'shopengine'), |
| 562 | 'icon' => 'fa fa-chevron-left' |
| 563 | ], |
| 564 | 'right' => [ |
| 565 | 'title' => esc_html__('Right', 'shopengine'), |
| 566 | 'icon' => 'fa fa-chevron-right' |
| 567 | ], |
| 568 | ], |
| 569 | 'selectors_dictionary' => [ |
| 570 | 'left' => 'right: auto; left: 0;', |
| 571 | 'right' => 'left: auto; right: 0;', |
| 572 | ], |
| 573 | 'selectors' => [ |
| 574 | '{{WRAPPER}} .shopengine-category-select-wraper:before' => '{{VALUE}};', |
| 575 | ], |
| 576 | 'separator' => 'before', |
| 577 | ] |
| 578 | ); |
| 579 | |
| 580 | $this->add_control( |
| 581 | 'shopengine_advanced_separator_width', |
| 582 | [ |
| 583 | 'label' => esc_html__('Separator Width', 'shopengine'), |
| 584 | 'type' => Controls_Manager::SLIDER, |
| 585 | 'size_units' => ['px'], |
| 586 | 'range' => [ |
| 587 | 'px' => [ |
| 588 | 'min' => 0, |
| 589 | 'max' => 100, |
| 590 | 'step' => 1, |
| 591 | ], |
| 592 | ], |
| 593 | 'selectors' => [ |
| 594 | '{{WRAPPER}} .shopengine-category-select-wraper:before' => 'border-width: {{SIZE}}{{UNIT}};', |
| 595 | ], |
| 596 | ] |
| 597 | ); |
| 598 | |
| 599 | $this->add_control( |
| 600 | 'shopengine_advanced_separator_color', |
| 601 | [ |
| 602 | 'label' => esc_html__('Separator Color', 'shopengine'), |
| 603 | 'type' => Controls_Manager::COLOR, |
| 604 | 'alpha' => false, |
| 605 | 'selectors' => [ |
| 606 | '{{WRAPPER}} .shopengine-category-select-wraper:before' => 'border-color: {{VALUE}}', |
| 607 | ], |
| 608 | 'condition' => [ |
| 609 | 'shopengine_advanced_separator_width!' => 0, |
| 610 | ], |
| 611 | ] |
| 612 | ); |
| 613 | |
| 614 | $this->add_responsive_control( |
| 615 | 'shopengine_advanced_separator_height', |
| 616 | [ |
| 617 | 'label' => esc_html__('Separator Height', 'shopengine'), |
| 618 | 'type' => Controls_Manager::SLIDER, |
| 619 | 'size_units' => ['%'], |
| 620 | 'range' => [ |
| 621 | '%' => [ |
| 622 | 'min' => 0, |
| 623 | 'max' => 100, |
| 624 | 'step' => 1, |
| 625 | ], |
| 626 | ], |
| 627 | 'selectors' => [ |
| 628 | '{{WRAPPER}} .shopengine-category-select-wraper:before' => 'height: {{SIZE}}%;', |
| 629 | ], |
| 630 | 'condition' => [ |
| 631 | 'shopengine_advanced_separator_width!' => 0, |
| 632 | ], |
| 633 | ] |
| 634 | ); |
| 635 | |
| 636 | |
| 637 | $this->end_controls_section(); // end ./ category style |
| 638 | |
| 639 | |
| 640 | /* |
| 641 | ------------------------------ |
| 642 | product wrap style |
| 643 | ------------------------------ |
| 644 | */ |
| 645 | $this->start_controls_section( |
| 646 | 'shopengine_advanced_product_wrap_section', |
| 647 | [ |
| 648 | 'label' => esc_html__('Product Style', 'shopengine'), |
| 649 | 'tab' => Controls_Manager::TAB_STYLE, |
| 650 | ] |
| 651 | ); |
| 652 | |
| 653 | $this->add_control( |
| 654 | 'shopengine_advanced_search_left_space', |
| 655 | [ |
| 656 | 'label' => esc_html__('Space On the Left', 'shopengine'), |
| 657 | 'description' => esc_html__('Add space on the left side of the search result container.', 'shopengine'), |
| 658 | 'type' => Controls_Manager::SLIDER, |
| 659 | 'size_units' => ['px'], |
| 660 | 'range' => [ |
| 661 | 'px' => [ |
| 662 | 'min' => 0, |
| 663 | 'max' => 300, |
| 664 | 'step' => 1, |
| 665 | ], |
| 666 | ], |
| 667 | 'default' => [ |
| 668 | 'unit' => 'px', |
| 669 | 'size' => 0, |
| 670 | ], |
| 671 | 'selectors' => [ |
| 672 | '{{WRAPPER}} .shopengine-search-result-container' => 'left: {{SIZE}}{{UNIT}}; width: calc(100% - {{SIZE}}{{UNIT}});', |
| 673 | ], |
| 674 | ] |
| 675 | ); |
| 676 | |
| 677 | $this->add_control( |
| 678 | 'shopengine_advanced_search_right_space', |
| 679 | [ |
| 680 | 'label' => esc_html__('Space On the Right', 'shopengine'), |
| 681 | 'description' => esc_html__('Add space on the right side of the search result container.', 'shopengine'), |
| 682 | 'type' => Controls_Manager::SLIDER, |
| 683 | 'size_units' => ['px'], |
| 684 | 'range' => [ |
| 685 | 'px' => [ |
| 686 | 'min' => 0, |
| 687 | 'max' => 300, |
| 688 | 'step' => 1, |
| 689 | ], |
| 690 | ], |
| 691 | 'default' => [ |
| 692 | 'unit' => 'px', |
| 693 | 'size' => 0, |
| 694 | ], |
| 695 | 'selectors' => [ |
| 696 | '{{WRAPPER}} .shopengine-search-result-container' => 'width: calc(100% - {{SIZE}}{{UNIT}});', |
| 697 | ], |
| 698 | 'condition' => [ |
| 699 | 'shopengine_advanced_search_left_space' => '0', |
| 700 | ], |
| 701 | ] |
| 702 | ); |
| 703 | |
| 704 | |
| 705 | |
| 706 | |
| 707 | $this->add_control( |
| 708 | 'shopengine_search_title_heading', |
| 709 | [ |
| 710 | 'label' => esc_html__('Title:', 'shopengine'), |
| 711 | 'type' => Controls_Manager::HEADING, |
| 712 | 'separator' => 'before', |
| 713 | ] |
| 714 | ); |
| 715 | |
| 716 | $this->add_control( |
| 717 | 'shopengine_advanced_search_product_title_clr', |
| 718 | [ |
| 719 | 'label' => esc_html__('Title color', 'shopengine'), |
| 720 | 'type' => Controls_Manager::COLOR, |
| 721 | 'default' => '#3E3E3E', |
| 722 | 'alpha' => false, |
| 723 | 'selectors' => [ |
| 724 | '{{WRAPPER}} .shopengine-advanced-search .shopengine-search-product__item--title a' => 'color: {{VALUE}}', |
| 725 | ], |
| 726 | ] |
| 727 | ); |
| 728 | |
| 729 | $this->add_control( |
| 730 | 'shopengine_advanced_search_product_title_hover_clr', |
| 731 | [ |
| 732 | 'label' => esc_html__('Title Hover color', 'shopengine'), |
| 733 | 'type' => Controls_Manager::COLOR, |
| 734 | 'default' => '#F03D3F', |
| 735 | 'alpha' => false, |
| 736 | 'selectors' => [ |
| 737 | '{{WRAPPER}} .shopengine-advanced-search .shopengine-search-product__item--title a:hover' => 'color: {{VALUE}}', |
| 738 | ], |
| 739 | ] |
| 740 | ); |
| 741 | |
| 742 | $this->add_group_control( |
| 743 | Group_Control_Typography::get_type(), |
| 744 | [ |
| 745 | 'name' => 'shopengine_advanced_search_product_title_typography', |
| 746 | 'label' => esc_html__('Title Typography', 'shopengine'), |
| 747 | 'selector' => '{{WRAPPER}} .shopengine-advanced-search .shopengine-search-product__item--title a', |
| 748 | 'exclude' => ['font_family', 'letter_spacing', 'text_decoration', 'font_style'], |
| 749 | |
| 750 | 'fields_options' => [ |
| 751 | 'typography' => [ |
| 752 | 'default' => 'custom', |
| 753 | ], |
| 754 | 'font_weight' => [ |
| 755 | 'default' => '500', |
| 756 | ], |
| 757 | 'font_size' => [ |
| 758 | 'label' => esc_html__('Font Size (px)', 'shopengine'), |
| 759 | 'default' => [ |
| 760 | 'size' => '15', |
| 761 | 'unit' => 'px', |
| 762 | ], |
| 763 | 'responsive' => false, |
| 764 | 'size_units' => ['px'], |
| 765 | ], |
| 766 | 'line_height' => [ |
| 767 | 'label' => esc_html__('Line-height (px)', 'shopengine'), |
| 768 | 'default' => [ |
| 769 | 'size' => '18', |
| 770 | 'unit' => 'px', |
| 771 | ], |
| 772 | 'responsive' => false, |
| 773 | 'size_units' => ['px'], |
| 774 | ], |
| 775 | ], |
| 776 | ] |
| 777 | ); |
| 778 | |
| 779 | |
| 780 | $this->add_control( |
| 781 | 'shopengine_search_price_heading', |
| 782 | [ |
| 783 | 'label' => __('Price:', 'shopengine'), |
| 784 | 'type' => Controls_Manager::HEADING, |
| 785 | 'separator' => 'before', |
| 786 | ] |
| 787 | ); |
| 788 | |
| 789 | $this->add_control( |
| 790 | 'shopengine_advanced_search_product_reg_price_clr', |
| 791 | [ |
| 792 | 'label' => esc_html__('Regular price color', 'shopengine'), |
| 793 | 'type' => Controls_Manager::COLOR, |
| 794 | 'default' => '#101010', |
| 795 | 'alpha' => false, |
| 796 | 'selectors' => [ |
| 797 | '{{WRAPPER}} .shopengine-advanced-search .shopengine-search-product__item--price ins .amount' => 'color: {{VALUE}}', |
| 798 | ], |
| 799 | ] |
| 800 | ); |
| 801 | |
| 802 | $this->add_control( |
| 803 | 'shopengine_advanced_search_product_sell_price_clr', |
| 804 | [ |
| 805 | 'label' => esc_html__('Sale Price Color', 'shopengine'), |
| 806 | 'type' => Controls_Manager::COLOR, |
| 807 | 'default' => '#999999', |
| 808 | 'alpha' => false, |
| 809 | 'selectors' => [ |
| 810 | '{{WRAPPER}} .shopengine-advanced-search .shopengine-search-product__item--price del .amount' => 'color: {{VALUE}}', |
| 811 | ], |
| 812 | ] |
| 813 | ); |
| 814 | |
| 815 | $this->add_group_control( |
| 816 | Group_Control_Typography::get_type(), |
| 817 | [ |
| 818 | 'name' => 'shopengine_advanced_search_product_price_typography', |
| 819 | 'label' => esc_html__('Price Typography', 'shopengine'), |
| 820 | 'selector' => '{{WRAPPER}} .shopengine-advanced-search .shopengine-search-product__item--price .amount', |
| 821 | 'exclude' => ['font_family', 'letter_spacing', 'text_decoration', 'font_style', 'line_height', 'text_transform'], |
| 822 | |
| 823 | 'fields_options' => [ |
| 824 | 'typography' => [ |
| 825 | 'default' => 'custom', |
| 826 | ], |
| 827 | 'font_weight' => [ |
| 828 | 'default' => '500', |
| 829 | ], |
| 830 | 'font_size' => [ |
| 831 | 'label' => esc_html__('Font Size (px)', 'shopengine'), |
| 832 | 'default' => [ |
| 833 | 'size' => '14', |
| 834 | 'unit' => 'px', |
| 835 | ], |
| 836 | 'responsive' => false, |
| 837 | 'size_units' => ['px'], |
| 838 | ], |
| 839 | ], |
| 840 | ] |
| 841 | ); |
| 842 | |
| 843 | $this->add_control( |
| 844 | 'shopengine_search_rating_heading', |
| 845 | [ |
| 846 | 'label' => __('Rating:', 'shopengine'), |
| 847 | 'type' => Controls_Manager::HEADING, |
| 848 | 'separator' => 'before', |
| 849 | ] |
| 850 | ); |
| 851 | |
| 852 | $this->add_control( |
| 853 | 'shopengine_search_rating_size', |
| 854 | [ |
| 855 | 'label' => __('Rating Font Size', 'shopengine'), |
| 856 | 'type' => Controls_Manager::SLIDER, |
| 857 | 'size_units' => ['px'], |
| 858 | 'range' => [ |
| 859 | 'px' => [ |
| 860 | 'min' => 0, |
| 861 | 'max' => 100, |
| 862 | 'step' => 1, |
| 863 | ], |
| 864 | ], |
| 865 | 'default' => [ |
| 866 | 'unit' => 'px', |
| 867 | 'size' => 10, |
| 868 | ], |
| 869 | 'selectors' => [ |
| 870 | '{{WRAPPER}} .shopengine-advanced-search .shopengine-product-rating .star-rating, {{WRAPPER}} .shopengine-advanced-search .shopengine-product-rating .rating-count' => 'font-size: {{SIZE}}{{UNIT}};', |
| 871 | ], |
| 872 | ] |
| 873 | ); |
| 874 | |
| 875 | $this->add_control( |
| 876 | 'shopengine_search_rating_color', |
| 877 | [ |
| 878 | 'label' => esc_html__('Star Color', 'shopengine'), |
| 879 | 'type' => Controls_Manager::COLOR, |
| 880 | 'alpha' => false, |
| 881 | 'default' => '#fec42d', |
| 882 | 'selectors' => [ |
| 883 | '{{WRAPPER}} .shopengine-product-rating .star-rating::before' => 'color: {{VALUE}};', |
| 884 | ], |
| 885 | ] |
| 886 | ); |
| 887 | |
| 888 | |
| 889 | |
| 890 | $this->add_control( |
| 891 | 'product_rating_count_color', |
| 892 | [ |
| 893 | 'label' => esc_html__('Counter', 'shopengine'), |
| 894 | 'type' => Controls_Manager::COLOR, |
| 895 | 'alpha' => false, |
| 896 | 'default' => '#858585', |
| 897 | 'selectors' => [ |
| 898 | '{{WRAPPER}} .shopengine-product-rating .rating-count' => 'color: {{VALUE}}', |
| 899 | ], |
| 900 | ] |
| 901 | ); |
| 902 | |
| 903 | |
| 904 | |
| 905 | $this->add_control( |
| 906 | 'shopengine_search_more_btn_heading', |
| 907 | [ |
| 908 | 'label' => __('Arrow Button:', 'shopengine'), |
| 909 | 'type' => Controls_Manager::HEADING, |
| 910 | 'separator' => 'before', |
| 911 | ] |
| 912 | ); |
| 913 | |
| 914 | $this->add_control( |
| 915 | 'shopengine_search_more_btn_icon_color', |
| 916 | [ |
| 917 | 'label' => esc_html__('Icon Color', 'shopengine'), |
| 918 | 'type' => Controls_Manager::COLOR, |
| 919 | 'default' => '#565969', |
| 920 | 'alpha' => false, |
| 921 | 'selectors' => [ |
| 922 | '{{WRAPPER}} .shopengine-search-more-btn' => 'color: {{VALUE}}', |
| 923 | ], |
| 924 | ] |
| 925 | ); |
| 926 | |
| 927 | $this->add_control( |
| 928 | 'shopengine_search_more_btn_icon_bg_color', |
| 929 | [ |
| 930 | 'label' => esc_html__('Icon Background Color', 'shopengine'), |
| 931 | 'type' => Controls_Manager::COLOR, |
| 932 | 'default' => 'rgba(86, 89, 105, 0.1)', |
| 933 | 'alpha' => false, |
| 934 | 'selectors' => [ |
| 935 | '{{WRAPPER}} .shopengine-advanced-search .shopengine-search-more-btn' => 'background-color: {{VALUE}}', |
| 936 | ], |
| 937 | ] |
| 938 | ); |
| 939 | |
| 940 | $this->add_control( |
| 941 | 'shopengine_search_more_btn_icon_bg_color_hover', |
| 942 | [ |
| 943 | 'label' => esc_html__('Icon Hover Background Color', 'shopengine'), |
| 944 | 'type' => Controls_Manager::COLOR, |
| 945 | 'default' => '#F03D3F', |
| 946 | 'alpha' => false, |
| 947 | 'selectors' => [ |
| 948 | '{{WRAPPER}} .shopengine-advanced-search .shopengine-search-product__item:hover .shopengine-search-more-btn' => 'background-color: {{VALUE}}', |
| 949 | ], |
| 950 | ] |
| 951 | ); |
| 952 | |
| 953 | $this->add_control( |
| 954 | 'shopengine_search_wrapper_heading', |
| 955 | [ |
| 956 | 'label' => __('Product Item:', 'shopengine'), |
| 957 | 'type' => Controls_Manager::HEADING, |
| 958 | 'separator' => 'before', |
| 959 | ] |
| 960 | ); |
| 961 | |
| 962 | $this->add_control( |
| 963 | 'shopengine_advanced_search_product_padding', |
| 964 | [ |
| 965 | 'label' => esc_html__('Wrapper Padding (px)', 'shopengine'), |
| 966 | 'type' => Controls_Manager::DIMENSIONS, |
| 967 | 'size_units' => ['px'], |
| 968 | 'default' => [ |
| 969 | 'top' => '10', |
| 970 | 'right' => '10', |
| 971 | 'bottom' => '10', |
| 972 | 'left' => '10', |
| 973 | 'unit' => 'px', |
| 974 | 'isLinked' => false, |
| 975 | ], |
| 976 | 'selectors' => [ |
| 977 | '{{WRAPPER}} .shopengine-advanced-search .shopengine-search-product__item' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 978 | ], |
| 979 | ] |
| 980 | ); |
| 981 | |
| 982 | $this->add_group_control( |
| 983 | Group_Control_Border::get_type(), |
| 984 | [ |
| 985 | 'name' => 'shopengine_advanced_search_product_border', |
| 986 | 'label' => esc_html__('Border', 'shopengine'), |
| 987 | 'selector' => '{{WRAPPER}} .shopengine-advanced-search :is( .shopengine-product-search-result, .shopengine-search-product__item)', |
| 988 | 'fields_options' => [ |
| 989 | 'border_type' => [ |
| 990 | 'default' => 'yes', |
| 991 | ], |
| 992 | 'border' => [ |
| 993 | 'default' => 'solid', |
| 994 | 'responsive' => false, |
| 995 | ], |
| 996 | |
| 997 | 'width' => [ |
| 998 | 'label' => esc_html__('Border Width', 'shopengine'), |
| 999 | 'default' => [ |
| 1000 | 'top' => '1', |
| 1001 | 'right' => '1', |
| 1002 | 'bottom' => '1', |
| 1003 | 'left' => '1', |
| 1004 | 'unit' => 'px', |
| 1005 | ], |
| 1006 | 'responsive' => false, |
| 1007 | ], |
| 1008 | |
| 1009 | 'color' => [ |
| 1010 | 'label' => esc_html__('Border Color', 'shopengine'), |
| 1011 | 'alpha' => false, |
| 1012 | 'default' => '#E6E6E6', |
| 1013 | 'responsive' => false, |
| 1014 | ], |
| 1015 | |
| 1016 | ], |
| 1017 | ] |
| 1018 | ); |
| 1019 | |
| 1020 | $this->end_controls_section(); // end ./ product wrap style |
| 1021 | |
| 1022 | // More Product button |
| 1023 | $this->start_controls_section( |
| 1024 | 'shopengine_advanced_search_more_btn', |
| 1025 | [ |
| 1026 | 'label' => esc_html__('More Products Button', 'shopengine'), |
| 1027 | 'tab' => Controls_Manager::TAB_STYLE, |
| 1028 | ] |
| 1029 | ); |
| 1030 | |
| 1031 | $this->add_control( |
| 1032 | 'shopengine_advanced_search_more_size', |
| 1033 | [ |
| 1034 | 'label' => esc_html__('Font Size', 'shopengine'), |
| 1035 | 'type' => Controls_Manager::SLIDER, |
| 1036 | 'size_units' => ['px'], |
| 1037 | 'range' => [ |
| 1038 | 'px' => [ |
| 1039 | 'min' => 0, |
| 1040 | 'max' => 1000, |
| 1041 | 'step' => 5, |
| 1042 | ], |
| 1043 | ], |
| 1044 | 'selectors' => [ |
| 1045 | '{{WRAPPER}} .shopengine-search-more-products' => 'font-size: {{SIZE}}{{UNIT}};', |
| 1046 | ], |
| 1047 | ] |
| 1048 | ); |
| 1049 | |
| 1050 | $this->add_control( |
| 1051 | 'shopengine_advanced_search_more_color', |
| 1052 | [ |
| 1053 | 'label' => esc_html__('Color', 'shopengine'), |
| 1054 | 'type' => Controls_Manager::COLOR, |
| 1055 | 'default' => '#F03D3F', |
| 1056 | 'alpha' => false, |
| 1057 | 'selectors' => [ |
| 1058 | '{{WRAPPER}} .shopengine-search-more-products' => 'color: {{VALUE}}', |
| 1059 | ], |
| 1060 | ] |
| 1061 | ); |
| 1062 | |
| 1063 | $this->add_control( |
| 1064 | 'shopengine_advanced_search_more_color_hover', |
| 1065 | [ |
| 1066 | 'label' => esc_html__('Hover Color', 'shopengine'), |
| 1067 | 'type' => Controls_Manager::COLOR, |
| 1068 | 'default' => '#bd1517', |
| 1069 | 'alpha' => false, |
| 1070 | 'selectors' => [ |
| 1071 | '{{WRAPPER}} .shopengine-search-more-products:hover' => 'color: {{VALUE}}', |
| 1072 | ], |
| 1073 | ] |
| 1074 | ); |
| 1075 | |
| 1076 | $this->end_controls_section(); |
| 1077 | |
| 1078 | //global font family |
| 1079 | $this->start_controls_section( |
| 1080 | 'shopengine_advanced_search_typography', |
| 1081 | array( |
| 1082 | 'label' => esc_html__('Global Font', 'shopengine'), |
| 1083 | 'tab' => Controls_Manager::TAB_STYLE, |
| 1084 | ) |
| 1085 | ); |
| 1086 | |
| 1087 | $this->add_control( |
| 1088 | 'shopengine_advanced_search_font_family', |
| 1089 | [ |
| 1090 | 'label' => esc_html__('Font Family', 'shopengine'), |
| 1091 | 'description' => esc_html__('This font family is set for this specific widget.', 'shopengine'), |
| 1092 | 'type' => Controls_Manager::FONT, |
| 1093 | 'default' => '', |
| 1094 | 'selectors' => [ |
| 1095 | '{{WRAPPER}} .shopengine-advanced-search .search-input-group :is( input, input::placeholder ), |
| 1096 | {{WRAPPER}} .shopengine-advanced-search .shopengine-search-text, |
| 1097 | {{WRAPPER}} .shopengine-advanced-search .shopengine-product-rating .rating-count, |
| 1098 | {{WRAPPER}} .shopengine-advanced-search .search-input-group :is( select ), |
| 1099 | {{WRAPPER}} .shopengine-advanced-search .shopengine-search-product__item--title, |
| 1100 | {{WRAPPER}} .shopengine-advanced-search .shopengine-search-product__item--price' => 'font-family: {{VALUE}}', |
| 1101 | ], |
| 1102 | ] |
| 1103 | ); |
| 1104 | |
| 1105 | $this->end_controls_section(); |
| 1106 | |
| 1107 | |
| 1108 | } |
| 1109 | |
| 1110 | protected function screen() { |
| 1111 | |
| 1112 | $settings = $this->get_settings_for_display(); |
| 1113 | $post_type = get_post_type(); |
| 1114 | |
| 1115 | $product = Products::instance()->get_product($post_type); |
| 1116 | |
| 1117 | $tpl = Products::instance()->get_widget_template($this->get_name()); |
| 1118 | |
| 1119 | include $tpl; |
| 1120 | } |
| 1121 | } |
| 1122 |