| 1 |
<?php |
| 2 |
/** |
| 3 |
* Main ProductDescription class. |
| 4 |
* |
| 5 |
* @package RadiusTheme\SB |
| 6 |
*/ |
| 7 |
|
| 8 |
namespace RadiusTheme\SB\Elementor\Widgets\Controls; |
| 9 |
|
| 10 |
use Elementor\Controls_Manager; |
| 11 |
use RadiusTheme\SB\Elementor\Widgets\Controls\ButtonSettings; |
| 12 |
use RadiusTheme\SB\Helpers\Fns; |
| 13 |
|
| 14 |
// Do not allow directly accessing this file. |
| 15 |
if ( ! defined( 'ABSPATH' ) ) { |
| 16 |
exit( 'This script cannot be accessed directly.' ); |
| 17 |
} |
| 18 |
|
| 19 |
/** |
| 20 |
* Product Description class |
| 21 |
*/ |
| 22 |
class AddToCartSettings { |
| 23 |
/** |
| 24 |
* Widget Control Selectors |
| 25 |
* |
| 26 |
* @var object |
| 27 |
*/ |
| 28 |
private static $widget = []; |
| 29 |
/** |
| 30 |
* Widget Control Selectors |
| 31 |
* |
| 32 |
* @var array |
| 33 |
*/ |
| 34 |
private static $selectors = []; |
| 35 |
/** |
| 36 |
* Widget Field |
| 37 |
* |
| 38 |
* @return array |
| 39 |
*/ |
| 40 |
public static function widget_fields( $widget ) { |
| 41 |
self::$widget = $widget; |
| 42 |
self::$selectors = $widget->selectors; |
| 43 |
return QuantityFields::quantity_fields( $widget ) + |
| 44 |
self::add_to_cart_fields() + |
| 45 |
self::add_to_cart_style() + |
| 46 |
self::product_price_style_fields() + |
| 47 |
QuantityFields::quantity_style_fields( $widget ) + |
| 48 |
self::variation_style_fields(); |
| 49 |
} |
| 50 |
|
| 51 |
/** |
| 52 |
* Widget Field |
| 53 |
* |
| 54 |
* @return array |
| 55 |
*/ |
| 56 |
public static function add_to_cart_fields() { |
| 57 |
$fields = [ |
| 58 |
'sec_add_to_cart' => [ |
| 59 |
'mode' => 'section_start', |
| 60 |
'label' => esc_html__( 'Add to cart', 'shopbuilder' ), |
| 61 |
], |
| 62 |
|
| 63 |
'cart_icon' => [ |
| 64 |
'label' => esc_html__( 'Cart Icon', 'shopbuilder' ), |
| 65 |
'type' => 'icons', |
| 66 |
'separator' => 'default', |
| 67 |
], |
| 68 |
'cart_icon_align' => [ |
| 69 |
'mode' => 'responsive', |
| 70 |
'label' => esc_html__( 'Icon Alignment', 'shopbuilder' ), |
| 71 |
'type' => 'choose', |
| 72 |
'options' => [ |
| 73 |
'0' => [ |
| 74 |
'title' => esc_html__( 'Left', 'shopbuilder' ), |
| 75 |
'icon' => 'fas fa-arrow-left', |
| 76 |
], |
| 77 |
'1' => [ |
| 78 |
'title' => esc_html__( 'Right', 'shopbuilder' ), |
| 79 |
'icon' => 'fas fa-arrow-right', |
| 80 |
], |
| 81 |
], |
| 82 |
'default' => '0', |
| 83 |
'condition' => [ |
| 84 |
'quantity_style!' => 'default', |
| 85 |
], |
| 86 |
'selectors' => [ |
| 87 |
self::$selectors['cart_icon_align']['icon'] => 'order: {{VALUE}};', |
| 88 |
self::$selectors['cart_icon_align']['svg'] => 'order: {{VALUE}};', |
| 89 |
], |
| 90 |
], |
| 91 |
'cart_icon_gap' => [ |
| 92 |
'label' => esc_html__( 'Gap', 'shopbuilder' ), |
| 93 |
'type' => 'slider', |
| 94 |
'mode' => 'responsive', |
| 95 |
'range' => [ |
| 96 |
'px' => [ |
| 97 |
'min' => 0, |
| 98 |
'max' => 100, |
| 99 |
], |
| 100 |
], |
| 101 |
'selectors' => [ |
| 102 |
self::$selectors['cart_icon_gap'] => 'gap: {{SIZE}}{{UNIT}};', |
| 103 |
], |
| 104 |
], |
| 105 |
'add_to_cart_end' => [ |
| 106 |
'mode' => 'section_end', |
| 107 |
], |
| 108 |
]; |
| 109 |
return $fields; |
| 110 |
} |
| 111 |
/** |
| 112 |
* Widget Field |
| 113 |
* |
| 114 |
* @return array |
| 115 |
*/ |
| 116 |
public static function add_to_cart_style() { |
| 117 |
$fields = ButtonSettings::style_settings( self::$widget ); |
| 118 |
$insert_array = [ |
| 119 |
'cart_icon_size' => [ |
| 120 |
'label' => esc_html__( 'Icon size', 'shopbuilder' ), |
| 121 |
'type' => 'slider', |
| 122 |
'separator' => 'default', |
| 123 |
'range' => [ |
| 124 |
'px' => [ |
| 125 |
'min' => 10, |
| 126 |
'max' => 50, |
| 127 |
], |
| 128 |
], |
| 129 |
'selectors' => [ |
| 130 |
self::$selectors['cart_icon_size']['icon'] => 'font-size: {{SIZE}}{{UNIT}};', |
| 131 |
self::$selectors['cart_icon_size']['svg'] => 'width: {{SIZE}}{{UNIT}}; height: {{SIZE}}{{UNIT}};', |
| 132 |
], |
| 133 |
], |
| 134 |
]; |
| 135 |
$fields = Fns::insert_controls( 'button_padding', $fields, $insert_array ); |
| 136 |
return $fields; |
| 137 |
} |
| 138 |
|
| 139 |
/** |
| 140 |
* Widget Field |
| 141 |
* |
| 142 |
* @return array |
| 143 |
*/ |
| 144 |
public static function quantity_style_fields() { |
| 145 |
$fields = [ |
| 146 |
'quantity_section' => [ |
| 147 |
'mode' => 'section_start', |
| 148 |
'tab' => 'style', |
| 149 |
'label' => esc_html__( 'Quantity', 'shopbuilder' ), |
| 150 |
], |
| 151 |
'quantity_style_heading' => [ |
| 152 |
'type' => 'html', |
| 153 |
'raw' => sprintf( |
| 154 |
'<h3 class="rtsb-elementor-group-heading">%s</h3>', |
| 155 |
esc_html__( 'Quantity Style', 'shopbuilder' ) |
| 156 |
), |
| 157 |
'content_classes' => 'elementor-panel-heading-title', |
| 158 |
'condition' => [ |
| 159 |
'quantity_style' => [ 'style-1', 'style-2' ], |
| 160 |
], |
| 161 |
], |
| 162 |
'icon_size' => [ |
| 163 |
'label' => esc_html__( 'Icon size', 'shopbuilder' ), |
| 164 |
'type' => 'slider', |
| 165 |
'separator' => 'default', |
| 166 |
'range' => [ |
| 167 |
'px' => [ |
| 168 |
'min' => 10, |
| 169 |
'max' => 50, |
| 170 |
], |
| 171 |
], |
| 172 |
'default' => [ |
| 173 |
'size' => 15, |
| 174 |
], |
| 175 |
'selectors' => [ |
| 176 |
self::$selectors['icon_size'] => 'font-size: {{SIZE}}{{UNIT}};', |
| 177 |
], |
| 178 |
], |
| 179 |
'quantitybox_border_color' => [ |
| 180 |
'label' => esc_html__( 'Border Color', 'shopbuilder' ), |
| 181 |
'type' => 'color', |
| 182 |
'selectors' => [ |
| 183 |
self::$selectors['quantitybox_border_color'] => 'border-color: {{VALUE}}', |
| 184 |
], |
| 185 |
], |
| 186 |
'quantity_icon_tabs_start' => [ |
| 187 |
'mode' => 'tabs_start', |
| 188 |
], |
| 189 |
// Tab For normal view. |
| 190 |
'quantity_icon_normal' => [ |
| 191 |
'mode' => 'tab_start', |
| 192 |
'label' => esc_html__( 'Normal', 'shopbuilder' ), |
| 193 |
], |
| 194 |
'quantity_icon_color' => [ |
| 195 |
'label' => esc_html__( 'Quantity icon Color', 'shopbuilder' ), |
| 196 |
'type' => 'color', |
| 197 |
'separator' => 'default', |
| 198 |
'selectors' => [ |
| 199 |
self::$selectors['quantity_icon_color'] => 'color: {{VALUE}}', |
| 200 |
], |
| 201 |
], |
| 202 |
'quantity_icon_normal_end' => [ |
| 203 |
'mode' => 'tab_end', |
| 204 |
], |
| 205 |
'quantity_icon_hover' => [ |
| 206 |
'mode' => 'tab_start', |
| 207 |
'label' => esc_html__( 'Hover', 'shopbuilder' ), |
| 208 |
], |
| 209 |
'quantity_icon_hover_color' => [ |
| 210 |
'label' => esc_html__( 'Quantity icon Color', 'shopbuilder' ), |
| 211 |
'type' => 'color', |
| 212 |
'separator' => 'default', |
| 213 |
'selectors' => [ |
| 214 |
self::$selectors['quantity_icon_hover_color'] => 'color: {{VALUE}}', |
| 215 |
], |
| 216 |
], |
| 217 |
'quantity_icon_hover_end' => [ |
| 218 |
'mode' => 'tab_end', |
| 219 |
], |
| 220 |
'quantity_icon_tabs_end' => [ |
| 221 |
'mode' => 'tabs_end', |
| 222 |
], |
| 223 |
|
| 224 |
'text_typography' => [ |
| 225 |
'type' => 'typography', |
| 226 |
'separator' => 'before', |
| 227 |
'mode' => 'group', |
| 228 |
'label' => esc_html__( 'Typography', 'shopbuilder' ), |
| 229 |
'description' => esc_html__( 'Only for Quantity Label.', 'shopbuilder' ), |
| 230 |
'selector' => self::$selectors['text_typography'], |
| 231 |
], |
| 232 |
'quantity_number_color' => [ |
| 233 |
'label' => esc_html__( 'Quantity Number', 'shopbuilder' ), |
| 234 |
'type' => 'color', |
| 235 |
'selectors' => [ |
| 236 |
self::$selectors['quantity_number_color'] => 'color: {{VALUE}}', |
| 237 |
], |
| 238 |
], |
| 239 |
'quantity_background_color' => [ |
| 240 |
'label' => esc_html__( 'Quantity Backgeound', 'shopbuilder' ), |
| 241 |
'type' => 'color', |
| 242 |
'selectors' => [ |
| 243 |
self::$selectors['quantity_background_color'] => 'background: {{VALUE}}', |
| 244 |
], |
| 245 |
], |
| 246 |
'quantity_border' => [ |
| 247 |
'mode' => 'group', |
| 248 |
'type' => 'border', |
| 249 |
'label' => esc_html__( 'Quantity Border', 'shopbuilder' ), |
| 250 |
'selector' => self::$selectors['quantity_border'], |
| 251 |
], |
| 252 |
'quantity_radius' => [ |
| 253 |
'label' => esc_html__( 'Border Radius', 'shopbuilder' ), |
| 254 |
'size_units' => [ 'px', '%' ], |
| 255 |
'type' => 'dimensions', |
| 256 |
'selectors' => [ |
| 257 |
self::$selectors['quantity_radius'] => 'border-radius: {{TOP}}px {{RIGHT}}px {{BOTTOM}}px {{LEFT}}px;', |
| 258 |
], |
| 259 |
], |
| 260 |
'qunatity_padding' => [ |
| 261 |
'label' => esc_html__( 'Padding', 'shopbuilder' ), |
| 262 |
'type' => 'dimensions', |
| 263 |
'mode' => 'responsive', |
| 264 |
'size_units' => [ 'px', '%', 'em' ], |
| 265 |
'selectors' => [ |
| 266 |
self::$selectors['qunatity_padding'] => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 267 |
], |
| 268 |
], |
| 269 |
'quantity_style_wrapper_heading' => [ |
| 270 |
'type' => 'html', |
| 271 |
'raw' => sprintf( |
| 272 |
'<h3 class="rtsb-elementor-group-heading">%s</h3>', |
| 273 |
esc_html__( 'Quantity Wrapper Style', 'shopbuilder' ) |
| 274 |
), |
| 275 |
'content_classes' => 'elementor-panel-heading-title', |
| 276 |
'condition' => [ |
| 277 |
'quantity_style' => [ 'style-1', 'style-2' ], |
| 278 |
], |
| 279 |
], |
| 280 |
'quantity_wrapper_background_color' => [ |
| 281 |
'label' => esc_html__( 'Background', 'shopbuilder' ), |
| 282 |
'type' => 'color', |
| 283 |
'selectors' => [ |
| 284 |
self::$selectors['quantity_wrapper_background_color'] => 'background: {{VALUE}}', |
| 285 |
], |
| 286 |
'condition' => [ |
| 287 |
'quantity_style' => [ 'style-1', 'style-2' ], |
| 288 |
], |
| 289 |
], |
| 290 |
'quantity_wrapper_radius' => [ |
| 291 |
'label' => esc_html__( 'Border Radius', 'shopbuilder' ), |
| 292 |
'size_units' => [ 'px', '%' ], |
| 293 |
'type' => 'dimensions', |
| 294 |
'selectors' => [ |
| 295 |
self::$selectors['quantity_wrapper_radius'] => 'border-radius: {{TOP}}px {{RIGHT}}px {{BOTTOM}}px {{LEFT}}px;', |
| 296 |
], |
| 297 |
'condition' => [ |
| 298 |
'quantity_style' => [ 'style-1', 'style-2' ], |
| 299 |
], |
| 300 |
], |
| 301 |
'qunatity_wrapper_padding' => [ |
| 302 |
'label' => esc_html__( 'Padding', 'shopbuilder' ), |
| 303 |
'type' => 'dimensions', |
| 304 |
'mode' => 'responsive', |
| 305 |
'size_units' => [ 'px', '%', 'em' ], |
| 306 |
'selectors' => [ |
| 307 |
self::$selectors['qunatity_wrapper_padding'] => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 308 |
], |
| 309 |
], |
| 310 |
'quantity_section_end' => [ |
| 311 |
'mode' => 'section_end', |
| 312 |
], |
| 313 |
]; |
| 314 |
return $fields; |
| 315 |
} |
| 316 |
|
| 317 |
/** |
| 318 |
* Widget Field |
| 319 |
* |
| 320 |
* @return array |
| 321 |
*/ |
| 322 |
public static function variation_style_fields() { |
| 323 |
$fields = [ |
| 324 |
'variation_section' => [ |
| 325 |
'mode' => 'section_start', |
| 326 |
'tab' => 'style', |
| 327 |
'label' => esc_html__( 'Variations', 'shopbuilder' ), |
| 328 |
], |
| 329 |
'variation_label_typography' => [ |
| 330 |
'type' => 'typography', |
| 331 |
'separator' => 'before', |
| 332 |
'mode' => 'group', |
| 333 |
'label' => esc_html__( 'Label Typography', 'shopbuilder' ), |
| 334 |
'description' => esc_html__( 'Only for Variation Label.', 'shopbuilder' ), |
| 335 |
'selector' => self::$selectors['variation_label_typography'], |
| 336 |
], |
| 337 |
'variation_stock_typography' => [ |
| 338 |
'type' => 'typography', |
| 339 |
'separator' => 'before', |
| 340 |
'mode' => 'group', |
| 341 |
'label' => esc_html__( 'Stock Typography', 'shopbuilder' ), |
| 342 |
'description' => esc_html__( 'Only for variation stock.', 'shopbuilder' ), |
| 343 |
'selector' => self::$selectors['variation_stock_typography'], |
| 344 |
], |
| 345 |
'variation_label_color' => [ |
| 346 |
'label' => esc_html__( 'Label Color', 'shopbuilder' ), |
| 347 |
'type' => 'color', |
| 348 |
'selectors' => [ |
| 349 |
self::$selectors['variation_label_color'] => 'color: {{VALUE}}', |
| 350 |
], |
| 351 |
], |
| 352 |
'variation_stock_color' => [ |
| 353 |
'label' => esc_html__( 'Stock Color', 'shopbuilder' ), |
| 354 |
'type' => 'color', |
| 355 |
'selectors' => [ |
| 356 |
self::$selectors['variation_stock_color'] => 'color: {{VALUE}}', |
| 357 |
], |
| 358 |
], |
| 359 |
'variation_outofstock_color' => [ |
| 360 |
'label' => esc_html__( 'Out of Stock Color', 'shopbuilder' ), |
| 361 |
'type' => 'color', |
| 362 |
'selectors' => [ |
| 363 |
self::$selectors['variation_outofstock_color'] => 'color: {{VALUE}}', |
| 364 |
], |
| 365 |
], |
| 366 |
'variation_height' => [ |
| 367 |
'label' => esc_html__( 'Height', 'shopbuilder' ), |
| 368 |
'type' => 'slider', |
| 369 |
'range' => [ |
| 370 |
'px' => [ |
| 371 |
'min' => 10, |
| 372 |
'max' => 200, |
| 373 |
], |
| 374 |
], |
| 375 |
'default' => [ |
| 376 |
'unit' => 'px', |
| 377 |
'size' => '30', |
| 378 |
], |
| 379 |
'selectors' => [ |
| 380 |
self::$selectors['variation_height'] => 'height: {{SIZE}}{{UNIT}};', |
| 381 |
], |
| 382 |
], |
| 383 |
'variation_width' => [ |
| 384 |
'label' => esc_html__( 'Min Width', 'shopbuilder' ), |
| 385 |
'size_units' => [ 'px', '%' ], |
| 386 |
'type' => 'slider', |
| 387 |
'range' => [ |
| 388 |
'px' => [ |
| 389 |
'min' => 10, |
| 390 |
'max' => 900, |
| 391 |
], |
| 392 |
'%' => [ |
| 393 |
'min' => 0, |
| 394 |
'max' => 100, |
| 395 |
], |
| 396 |
], |
| 397 |
'default' => [ |
| 398 |
'unit' => 'px', |
| 399 |
'size' => '30', |
| 400 |
], |
| 401 |
'selectors' => [ |
| 402 |
self::$selectors['variation_width'] => 'min-width: {{SIZE}}{{UNIT}};', |
| 403 |
], |
| 404 |
], |
| 405 |
'variation_border' => [ |
| 406 |
'mode' => 'group', |
| 407 |
'type' => 'border', |
| 408 |
'label' => esc_html__( 'Quantity Border', 'shopbuilder' ), |
| 409 |
'selector' => self::$selectors['variation_border'], |
| 410 |
], |
| 411 |
'variation_border_radius' => [ |
| 412 |
'label' => esc_html__( 'Border Radius', 'shopbuilder' ), |
| 413 |
'size_units' => [ 'px', '%' ], |
| 414 |
'type' => 'slider', |
| 415 |
'selectors' => [ |
| 416 |
self::$selectors['variation_border_radius'] => 'border-radius: {{SIZE}}{{UNIT}};', |
| 417 |
], |
| 418 |
], |
| 419 |
'variation_padding' => [ |
| 420 |
'label' => esc_html__( 'Padding ', 'shopbuilder' ), |
| 421 |
'description' => esc_html__( 'Note: Only for Select And Button Field.', 'shopbuilder' ), |
| 422 |
'type' => 'dimensions', |
| 423 |
'size_units' => [ 'px' ], |
| 424 |
'default' => [ |
| 425 |
'top' => '10', |
| 426 |
'right' => '10', |
| 427 |
'bottom' => '10', |
| 428 |
'left' => '10', |
| 429 |
'unit' => 'px', |
| 430 |
'isLinked' => true, |
| 431 |
], |
| 432 |
'separator' => 'default', |
| 433 |
'selectors' => [ |
| 434 |
self::$selectors['variation_padding'] => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 435 |
], |
| 436 |
], |
| 437 |
'variation_label_margin' => [ |
| 438 |
'label' => esc_html__( 'Label Margin', 'shopbuilder' ), |
| 439 |
'type' => 'dimensions', |
| 440 |
'size_units' => [ 'px', '%', 'em' ], |
| 441 |
'selectors' => [ |
| 442 |
self::$selectors['variation_label_margin'] => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}} !important;', |
| 443 |
], |
| 444 |
], |
| 445 |
'variation_item_margin' => [ |
| 446 |
'label' => esc_html__( 'Variation Item Margin', 'shopbuilder' ), |
| 447 |
'type' => 'dimensions', |
| 448 |
'size_units' => [ 'px', '%', 'em' ], |
| 449 |
'selectors' => [ |
| 450 |
self::$selectors['variation_item_margin'] => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}} !important;', |
| 451 |
], |
| 452 |
], |
| 453 |
'variation_section_end' => [ |
| 454 |
'mode' => 'section_end', |
| 455 |
], |
| 456 |
]; |
| 457 |
return $fields; |
| 458 |
} |
| 459 |
|
| 460 |
/** |
| 461 |
* Widget Field |
| 462 |
* |
| 463 |
* @return array |
| 464 |
*/ |
| 465 |
public static function product_price_style_fields() { |
| 466 |
return [ |
| 467 |
'price_section_style_start' => [ |
| 468 |
'mode' => 'section_start', |
| 469 |
'tab' => 'style', |
| 470 |
'label' => esc_html__( 'Price', 'shopbuilder' ), |
| 471 |
], |
| 472 |
'price_typography' => [ |
| 473 |
'type' => 'typography', |
| 474 |
'separator' => 'before', |
| 475 |
'mode' => 'group', |
| 476 |
'label' => esc_html__( 'Typography', 'shopbuilder' ), |
| 477 |
'description' => esc_html__( 'Only for Variation Price', 'shopbuilder' ), |
| 478 |
'selector' => self::$selectors['price_typography'], |
| 479 |
], |
| 480 |
'price_color' => [ |
| 481 |
'label' => esc_html__( 'Color', 'shopbuilder' ), |
| 482 |
'type' => 'color', |
| 483 |
'selectors' => [ |
| 484 |
self::$selectors['price_color'] => 'color: {{VALUE}}', |
| 485 |
], |
| 486 |
], |
| 487 |
'price_margin' => [ |
| 488 |
'label' => esc_html__( 'Margin', 'shopbuilder' ), |
| 489 |
'type' => 'dimensions', |
| 490 |
'size_units' => [ 'px' ], |
| 491 |
'separator' => 'default', |
| 492 |
'selectors' => [ |
| 493 |
self::$selectors['price_margin'] => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 494 |
], |
| 495 |
], |
| 496 |
'price_section_style_end' => [ |
| 497 |
'mode' => 'section_end', |
| 498 |
], |
| 499 |
]; |
| 500 |
} |
| 501 |
} |
| 502 |
|