| 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 self::quantity_fields() + |
| 44 |
self::add_to_cart_fields() + |
| 45 |
self::add_to_cart_style() + |
| 46 |
self::quantity_style_fields() + |
| 47 |
self::variation_style_fields(); |
| 48 |
} |
| 49 |
/** |
| 50 |
* Widget Field |
| 51 |
* |
| 52 |
* @return array |
| 53 |
*/ |
| 54 |
public static function quantity_fields() { |
| 55 |
$fields = [ |
| 56 |
'sec_quantity' => [ |
| 57 |
'mode' => 'section_start', |
| 58 |
'label' => esc_html__( 'Quantity', 'shopbuilder' ), |
| 59 |
], |
| 60 |
// TODO:: Control Type will be select image. |
| 61 |
'quantity_style' => [ |
| 62 |
'label' => esc_html__( 'Style', 'shopbuilder' ), |
| 63 |
'type' => 'select', |
| 64 |
'options' => [ |
| 65 |
'default' => esc_html__( 'Default', 'shopbuilder' ), |
| 66 |
'style-1' => esc_html__( 'Style 1', 'shopbuilder' ), |
| 67 |
'style-2' => esc_html__( 'Style 2', 'shopbuilder' ), |
| 68 |
'style-3' => esc_html__( 'Style 3', 'shopbuilder' ), |
| 69 |
'style-4' => esc_html__( 'Style 4', 'shopbuilder' ), |
| 70 |
], |
| 71 |
'separator' => 'default', |
| 72 |
'default' => 'default', |
| 73 |
], |
| 74 |
'height' => [ |
| 75 |
'label' => esc_html__( 'Height', 'shopbuilder' ), |
| 76 |
'type' => 'slider', |
| 77 |
'range' => [ |
| 78 |
'px' => [ |
| 79 |
'min' => 10, |
| 80 |
'max' => 200, |
| 81 |
], |
| 82 |
], |
| 83 |
'default' => [ |
| 84 |
'size' => 50, |
| 85 |
], |
| 86 |
'selectors' => [ |
| 87 |
self::$selectors['height']['full'] => 'height: {{SIZE}}{{UNIT}};', |
| 88 |
self::$selectors['height']['half'] => 'height: calc( {{SIZE}}{{UNIT}} / 2 );', |
| 89 |
], |
| 90 |
], |
| 91 |
'increment_icon' => [ |
| 92 |
'label' => esc_html__( 'Increment Icon', 'shopbuilder' ), |
| 93 |
'type' => 'icons', |
| 94 |
'default' => [ |
| 95 |
'value' => 'fas fa-plus', |
| 96 |
'library' => 'fa-solid', |
| 97 |
], |
| 98 |
'condition' => [ |
| 99 |
'quantity_style!' => 'default', |
| 100 |
], |
| 101 |
], |
| 102 |
'decrement_icon' => [ |
| 103 |
'label' => esc_html__( 'Decrement Icon', 'shopbuilder' ), |
| 104 |
'type' => 'icons', |
| 105 |
'default' => [ |
| 106 |
'value' => 'fas fa-minus', |
| 107 |
'library' => 'fa-solid', |
| 108 |
], |
| 109 |
'condition' => [ |
| 110 |
'quantity_style!' => 'default', |
| 111 |
], |
| 112 |
], |
| 113 |
'quantity_style_end' => [ |
| 114 |
'mode' => 'section_end', |
| 115 |
], |
| 116 |
]; |
| 117 |
return $fields; |
| 118 |
} |
| 119 |
/** |
| 120 |
* Widget Field |
| 121 |
* |
| 122 |
* @return array |
| 123 |
*/ |
| 124 |
public static function add_to_cart_fields() { |
| 125 |
$fields = [ |
| 126 |
'sec_add_to_cart' => [ |
| 127 |
'mode' => 'section_start', |
| 128 |
'label' => esc_html__( 'Add to cart', 'shopbuilder' ), |
| 129 |
], |
| 130 |
|
| 131 |
'cart_icon' => [ |
| 132 |
'label' => esc_html__( 'Cart Icon', 'shopbuilder' ), |
| 133 |
'type' => 'icons', |
| 134 |
'separator' => 'default' |
| 135 |
], |
| 136 |
'cart_icon_align' => [ |
| 137 |
'mode' => 'responsive', |
| 138 |
'label' => esc_html__( 'Icon Alignment', 'shopbuilder' ), |
| 139 |
'type' => 'choose', |
| 140 |
'options' => [ |
| 141 |
'0' => [ |
| 142 |
'title' => esc_html__( 'Left', 'shopbuilder' ), |
| 143 |
'icon' => 'fas fa-arrow-left', |
| 144 |
], |
| 145 |
'1' => [ |
| 146 |
'title' => esc_html__( 'Right', 'shopbuilder' ), |
| 147 |
'icon' => 'fas fa-arrow-right', |
| 148 |
], |
| 149 |
], |
| 150 |
'default' => '0', |
| 151 |
'condition' => [ |
| 152 |
'quantity_style!' => 'default', |
| 153 |
], |
| 154 |
'selectors' => [ |
| 155 |
self::$selectors['cart_icon_align'] => 'order: {{VALUE}};', |
| 156 |
], |
| 157 |
], |
| 158 |
'cart_icon_gap' => [ |
| 159 |
'label' => esc_html__( 'Gap', 'shopbuilder' ), |
| 160 |
'type' => 'slider', |
| 161 |
'range' => [ |
| 162 |
'px' => [ |
| 163 |
'min' => 0, |
| 164 |
'max' => 100, |
| 165 |
], |
| 166 |
], |
| 167 |
'selectors' => [ |
| 168 |
self::$selectors['cart_icon_gap'] => 'gap: {{SIZE}}{{UNIT}};', |
| 169 |
], |
| 170 |
], |
| 171 |
'add_to_cart_end' => [ |
| 172 |
'mode' => 'section_end', |
| 173 |
], |
| 174 |
]; |
| 175 |
return $fields; |
| 176 |
} |
| 177 |
/** |
| 178 |
* Widget Field |
| 179 |
* |
| 180 |
* @return array |
| 181 |
*/ |
| 182 |
public static function add_to_cart_style() { |
| 183 |
$fields = ButtonSettings::style_settings( self::$widget ); |
| 184 |
$insert_array = [ |
| 185 |
'cart_icon_size' => [ |
| 186 |
'label' => esc_html__( 'Icon size', 'shopbuilder' ), |
| 187 |
'type' => 'slider', |
| 188 |
'separator' => 'default', |
| 189 |
'range' => [ |
| 190 |
'px' => [ |
| 191 |
'min' => 10, |
| 192 |
'max' => 50, |
| 193 |
], |
| 194 |
], |
| 195 |
'selectors' => [ |
| 196 |
self::$selectors['cart_icon_size'] => 'font-size: {{SIZE}}{{UNIT}};', |
| 197 |
], |
| 198 |
], |
| 199 |
]; |
| 200 |
$fields = Fns::insert_controls( 'button_padding', $fields, $insert_array ); |
| 201 |
return $fields; |
| 202 |
} |
| 203 |
|
| 204 |
/** |
| 205 |
* Widget Field |
| 206 |
* |
| 207 |
* @return array |
| 208 |
*/ |
| 209 |
public static function quantity_style_fields() { |
| 210 |
$fields = [ |
| 211 |
'quantity_section' => [ |
| 212 |
'mode' => 'section_start', |
| 213 |
'tab' => 'style', |
| 214 |
'label' => esc_html__( 'Quantity', 'shopbuilder' ), |
| 215 |
], |
| 216 |
'icon_size' => [ |
| 217 |
'label' => esc_html__( 'Icon size', 'shopbuilder' ), |
| 218 |
'type' => 'slider', |
| 219 |
'separator' => 'default', |
| 220 |
'range' => [ |
| 221 |
'px' => [ |
| 222 |
'min' => 10, |
| 223 |
'max' => 50, |
| 224 |
], |
| 225 |
], |
| 226 |
'default' => [ |
| 227 |
'size' => 15, |
| 228 |
], |
| 229 |
'selectors' => [ |
| 230 |
self::$selectors['icon_size'] => 'font-size: {{SIZE}}{{UNIT}};', |
| 231 |
], |
| 232 |
], |
| 233 |
'quantitybox_border_color' => [ |
| 234 |
'label' => esc_html__( 'Border Color', 'shopbuilder' ), |
| 235 |
'type' => 'color', |
| 236 |
'selectors' => [ |
| 237 |
self::$selectors['quantitybox_border_color'] => 'border-color: {{VALUE}}', |
| 238 |
], |
| 239 |
], |
| 240 |
'quantity_icon_tabs_start' => [ |
| 241 |
'mode' => 'tabs_start', |
| 242 |
], |
| 243 |
// Tab For normal view. |
| 244 |
'quantity_icon_normal' => [ |
| 245 |
'mode' => 'tab_start', |
| 246 |
'label' => esc_html__( 'Normal', 'shopbuilder' ), |
| 247 |
], |
| 248 |
'quantity_icon_color' => [ |
| 249 |
'label' => esc_html__( 'Quantity icon Color', 'shopbuilder' ), |
| 250 |
'type' => 'color', |
| 251 |
'separator' => 'default', |
| 252 |
'selectors' => [ |
| 253 |
self::$selectors['quantity_icon_color'] => 'color: {{VALUE}}', |
| 254 |
], |
| 255 |
], |
| 256 |
'quantity_icon_normal_end' => [ |
| 257 |
'mode' => 'tab_end', |
| 258 |
], |
| 259 |
'quantity_icon_hover' => [ |
| 260 |
'mode' => 'tab_start', |
| 261 |
'label' => esc_html__( 'Hover', 'shopbuilder' ), |
| 262 |
], |
| 263 |
'quantity_icon_hover_color' => [ |
| 264 |
'label' => esc_html__( 'Quantity icon Color', 'shopbuilder' ), |
| 265 |
'type' => 'color', |
| 266 |
'separator' => 'default', |
| 267 |
'selectors' => [ |
| 268 |
self::$selectors['quantity_icon_hover_color'] => 'color: {{VALUE}}', |
| 269 |
], |
| 270 |
], |
| 271 |
'quantity_icon_hover_end' => [ |
| 272 |
'mode' => 'tab_end', |
| 273 |
], |
| 274 |
'quantity_icon_tabs_end' => [ |
| 275 |
'mode' => 'tabs_end', |
| 276 |
], |
| 277 |
|
| 278 |
'text_typography' => [ |
| 279 |
'type' => 'typography', |
| 280 |
'separator' => 'before', |
| 281 |
'mode' => 'group', |
| 282 |
'label' => esc_html__( 'Typography', 'shopbuilder' ), |
| 283 |
'description' => esc_html__( 'Only for Quantity Label.', 'shopbuilder' ), |
| 284 |
'selector' => self::$selectors['text_typography'], |
| 285 |
], |
| 286 |
'quantity_number_color' => [ |
| 287 |
'label' => esc_html__( 'Quantity Number', 'shopbuilder' ), |
| 288 |
'type' => 'color', |
| 289 |
'selectors' => [ |
| 290 |
self::$selectors['quantity_number_color'] => 'color: {{VALUE}}', |
| 291 |
], |
| 292 |
], |
| 293 |
'quantity_background_color' => [ |
| 294 |
'label' => esc_html__( 'Quantity Backgeound', 'shopbuilder' ), |
| 295 |
'type' => 'color', |
| 296 |
'selectors' => [ |
| 297 |
self::$selectors['quantity_background_color'] => 'background: {{VALUE}}', |
| 298 |
], |
| 299 |
], |
| 300 |
'quantity_border' => [ |
| 301 |
'mode' => 'group', |
| 302 |
'type' => 'border', |
| 303 |
'label' => esc_html__( 'Quantity Border', 'shopbuilder' ), |
| 304 |
'selector' => self::$selectors['quantity_border'], |
| 305 |
], |
| 306 |
'quantity_radius' => [ |
| 307 |
'label' => esc_html__( 'Border Radius', 'shopbuilder' ), |
| 308 |
'size_units' => [ 'px', '%' ], |
| 309 |
'type' => 'dimensions', |
| 310 |
'selectors' => [ |
| 311 |
self::$selectors['quantity_radius'] => 'border-radius: {{TOP}}px {{RIGHT}}px {{BOTTOM}}px {{LEFT}}px;', |
| 312 |
], |
| 313 |
], |
| 314 |
'qunatity_padding' => [ |
| 315 |
'label' => esc_html__( 'Padding', 'shopbuilder' ), |
| 316 |
'type' => 'dimensions', |
| 317 |
'size_units' => [ 'px', '%', 'em' ], |
| 318 |
'selectors' => [ |
| 319 |
self::$selectors['qunatity_padding'] => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 320 |
], |
| 321 |
], |
| 322 |
|
| 323 |
'quantity_section_end' => [ |
| 324 |
'mode' => 'section_end', |
| 325 |
], |
| 326 |
]; |
| 327 |
return $fields; |
| 328 |
} |
| 329 |
|
| 330 |
/** |
| 331 |
* Widget Field |
| 332 |
* |
| 333 |
* @return array |
| 334 |
*/ |
| 335 |
public static function variation_style_fields() { |
| 336 |
$fields = [ |
| 337 |
'variation_section' => [ |
| 338 |
'mode' => 'section_start', |
| 339 |
'tab' => 'style', |
| 340 |
'label' => esc_html__( 'Variations', 'shopbuilder' ), |
| 341 |
], |
| 342 |
'variation_padding' => [ |
| 343 |
'label' => esc_html__( 'Padding', 'shopbuilder' ), |
| 344 |
'type' => 'dimensions', |
| 345 |
'size_units' => [ 'px' ], |
| 346 |
'default' => [ |
| 347 |
'top' => '10', |
| 348 |
'right' => '10', |
| 349 |
'bottom' => '10', |
| 350 |
'left' => '10', |
| 351 |
'unit' => 'px', |
| 352 |
'isLinked' => true, |
| 353 |
], |
| 354 |
'separator' => 'default', |
| 355 |
'selectors' => [ |
| 356 |
self::$selectors['variation_padding'] => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 357 |
], |
| 358 |
], |
| 359 |
'variation_border' => [ |
| 360 |
'mode' => 'group', |
| 361 |
'type' => 'border', |
| 362 |
'label' => esc_html__( 'Quantity Border', 'shopbuilder' ), |
| 363 |
'selector' => self::$selectors['variation_border'], |
| 364 |
], |
| 365 |
'variation_section_end' => [ |
| 366 |
'mode' => 'section_end', |
| 367 |
], |
| 368 |
]; |
| 369 |
return $fields; |
| 370 |
} |
| 371 |
|
| 372 |
|
| 373 |
} |
| 374 |
|