# shopbuilder/1.1.4/app/Elementor/Widgets/Controls/AddToCartSettings.php

ShopBuilder – WooCommerce Builder For Elementor, version 1.1.4. 374 lines.

- Page: https://pluginprobe.com/plugins/shopbuilder/1.1.4/code/app/Elementor/Widgets/Controls/AddToCartSettings.php
- Raw: https://pluginprobe.com/plugins/shopbuilder/1.1.4/raw/app/Elementor/Widgets/Controls/AddToCartSettings.php
- Modified: 2023-07-11T10:48:20+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/shopbuilder/1.1.4/code/app/Elementor/Widgets/Controls/AddToCartSettings.php#L10-L20`.

```php
<?php
/**
 * Main ProductDescription class.
 *
 * @package RadiusTheme\SB
 */

namespace RadiusTheme\SB\Elementor\Widgets\Controls;

use Elementor\Controls_Manager;
use RadiusTheme\SB\Elementor\Widgets\Controls\ButtonSettings;
use RadiusTheme\SB\Helpers\Fns;

// Do not allow directly accessing this file.
if ( ! defined( 'ABSPATH' ) ) {
	exit( 'This script cannot be accessed directly.' );
}

/**
 * Product Description class
 */
class AddToCartSettings {
    /**
     * Widget Control Selectors
     *
     * @var object
     */
    private static $widget = [];
	/**
	 * Widget Control Selectors
	 *
	 * @var array
	 */
	private static $selectors = [];
	/**
	 * Widget Field
	 *
	 * @return array
	 */
	public static function widget_fields( $widget ) {
        self::$widget = $widget;
		self::$selectors = $widget->selectors;
		return self::quantity_fields() +
			self::add_to_cart_fields() +
			self::add_to_cart_style() +
			self::quantity_style_fields() +
			self::variation_style_fields();
	}
	/**
	 * Widget Field
	 *
	 * @return array
	 */
	public static function quantity_fields() {
		$fields = [
			'sec_quantity'       => [
				'mode'  => 'section_start',
				'label' => esc_html__( 'Quantity', 'shopbuilder' ),
			],
			// TODO:: Control Type will be select image.
			'quantity_style'     => [
				'label'     => esc_html__( 'Style', 'shopbuilder' ),
				'type'      => 'select',
				'options'   => [
					'default' => esc_html__( 'Default', 'shopbuilder' ),
					'style-1' => esc_html__( 'Style 1', 'shopbuilder' ),
					'style-2' => esc_html__( 'Style 2', 'shopbuilder' ),
					'style-3' => esc_html__( 'Style 3', 'shopbuilder' ),
					'style-4' => esc_html__( 'Style 4', 'shopbuilder' ),
				],
				'separator' => 'default',
				'default'   => 'default',
			],
			'height'             => [
				'label'     => esc_html__( 'Height', 'shopbuilder' ),
				'type'      => 'slider',
				'range'     => [
					'px' => [
						'min' => 10,
						'max' => 200,
					],
				],
				'default'   => [
					'size' => 50,
				],
				'selectors' => [
					self::$selectors['height']['full'] => 'height: {{SIZE}}{{UNIT}};',
					self::$selectors['height']['half'] => 'height: calc( {{SIZE}}{{UNIT}} / 2 );',
				],
			],
			'increment_icon'     => [
				'label'     => esc_html__( 'Increment Icon', 'shopbuilder' ),
				'type'      => 'icons',
				'default'   => [
					'value'   => 'fas fa-plus',
					'library' => 'fa-solid',
				],
				'condition' => [
					'quantity_style!' => 'default',
				],
			],
			'decrement_icon'     => [
				'label'     => esc_html__( 'Decrement Icon', 'shopbuilder' ),
				'type'      => 'icons',
				'default'   => [
					'value'   => 'fas fa-minus',
					'library' => 'fa-solid',
				],
				'condition' => [
					'quantity_style!' => 'default',
				],
			],
			'quantity_style_end' => [
				'mode' => 'section_end',
			],
		];
		return $fields;
	}
	/**
	 * Widget Field
	 *
	 * @return array
	 */
	public static function add_to_cart_fields() {
		$fields = [
			'sec_add_to_cart' => [
				'mode'  => 'section_start',
				'label' => esc_html__( 'Add to cart', 'shopbuilder' ),
			],

			'cart_icon'       => [
				'label'     => esc_html__( 'Cart Icon', 'shopbuilder' ),
				'type'      => 'icons',
                'separator' => 'default'
			],
			'cart_icon_align'     => [
				'mode'      => 'responsive',
				'label'     => esc_html__( 'Icon Alignment', 'shopbuilder' ),
				'type'      => 'choose',
				'options'   => [
					'0' => [
						'title' => esc_html__( 'Left', 'shopbuilder' ),
						'icon'  => 'fas fa-arrow-left',
					],
					'1' => [
						'title' => esc_html__( 'Right', 'shopbuilder' ),
						'icon'  => 'fas fa-arrow-right',
					],
				],
				'default'   => '0',
				'condition' => [
					'quantity_style!' => 'default',
				],
				'selectors' => [
					self::$selectors['cart_icon_align'] => 'order: {{VALUE}};',
				],
			],
			'cart_icon_gap'   => [
				'label'     => esc_html__( 'Gap', 'shopbuilder' ),
				'type'      => 'slider',
				'range'     => [
					'px' => [
						'min' => 0,
						'max' => 100,
					],
				],
				'selectors' => [
					self::$selectors['cart_icon_gap'] => 'gap: {{SIZE}}{{UNIT}};',
				],
			],
			'add_to_cart_end' => [
				'mode' => 'section_end',
			],
		];
		return $fields;
	}
	/**
	 * Widget Field
	 *
	 * @return array
	 */
	public static function add_to_cart_style() {
        $fields = ButtonSettings::style_settings( self::$widget );
        $insert_array = [
            'cart_icon_size'                 => [
                'label'     => esc_html__( 'Icon size', 'shopbuilder' ),
                'type'      => 'slider',
                'separator' => 'default',
                'range'     => [
                    'px' => [
                        'min' => 10,
                        'max' => 50,
                    ],
                ],
                'selectors' => [
                    self::$selectors['cart_icon_size'] => 'font-size: {{SIZE}}{{UNIT}};',
                ],
            ],
        ];
        $fields       = Fns::insert_controls( 'button_padding', $fields, $insert_array );
		return $fields;
	}

	/**
	 * Widget Field
	 *
	 * @return array
	 */
	public static function quantity_style_fields() {
		$fields = [
			'quantity_section'          => [
				'mode'  => 'section_start',
				'tab'   => 'style',
				'label' => esc_html__( 'Quantity', 'shopbuilder' ),
			],
			'icon_size'                 => [
				'label'     => esc_html__( 'Icon size', 'shopbuilder' ),
				'type'      => 'slider',
				'separator' => 'default',
				'range'     => [
					'px' => [
						'min' => 10,
						'max' => 50,
					],
				],
				'default'   => [
					'size' => 15,
				],
				'selectors' => [
					self::$selectors['icon_size'] => 'font-size: {{SIZE}}{{UNIT}};',
				],
			],
            'quantitybox_border_color' => [
                'label'     => esc_html__( 'Border Color', 'shopbuilder' ),
                'type'      => 'color',
                'selectors' => [
                    self::$selectors['quantitybox_border_color'] => 'border-color: {{VALUE}}',
                ],
            ],
			'quantity_icon_tabs_start'  => [
				'mode' => 'tabs_start',
			],
			// Tab For normal view.
			'quantity_icon_normal'      => [
				'mode'  => 'tab_start',
				'label' => esc_html__( 'Normal', 'shopbuilder' ),
			],
			'quantity_icon_color'       => [
				'label'     => esc_html__( 'Quantity icon Color', 'shopbuilder' ),
				'type'      => 'color',
				'separator' => 'default',
				'selectors' => [
					self::$selectors['quantity_icon_color'] => 'color: {{VALUE}}',
				],
			],
			'quantity_icon_normal_end'  => [
				'mode' => 'tab_end',
			],
			'quantity_icon_hover'       => [
				'mode'  => 'tab_start',
				'label' => esc_html__( 'Hover', 'shopbuilder' ),
			],
			'quantity_icon_hover_color' => [
				'label'     => esc_html__( 'Quantity icon Color', 'shopbuilder' ),
				'type'      => 'color',
				'separator' => 'default',
				'selectors' => [
					self::$selectors['quantity_icon_hover_color'] => 'color: {{VALUE}}',
				],
			],
			'quantity_icon_hover_end'   => [
				'mode' => 'tab_end',
			],
			'quantity_icon_tabs_end'    => [
				'mode' => 'tabs_end',
			],

			'text_typography'           => [
				'type'        => 'typography',
				'separator'   => 'before',
				'mode'        => 'group',
				'label'       => esc_html__( 'Typography', 'shopbuilder' ),
				'description' => esc_html__( 'Only for Quantity Label.', 'shopbuilder' ),
				'selector'    => self::$selectors['text_typography'],
			],
			'quantity_number_color'     => [
				'label'     => esc_html__( 'Quantity Number', 'shopbuilder' ),
				'type'      => 'color',
				'selectors' => [
					self::$selectors['quantity_number_color'] => 'color: {{VALUE}}',
				],
			],
			'quantity_background_color' => [
				'label'     => esc_html__( 'Quantity Backgeound', 'shopbuilder' ),
				'type'      => 'color',
				'selectors' => [
					self::$selectors['quantity_background_color'] => 'background: {{VALUE}}',
				],
			],
			'quantity_border'           => [
				'mode'     => 'group',
				'type'     => 'border',
				'label'    => esc_html__( 'Quantity Border', 'shopbuilder' ),
				'selector' => self::$selectors['quantity_border'],
			],
			'quantity_radius'           => [
				'label'      => esc_html__( 'Border Radius', 'shopbuilder' ),
				'size_units' => [ 'px', '%' ],
				'type'       => 'dimensions',
				'selectors'  => [
					self::$selectors['quantity_radius'] => 'border-radius: {{TOP}}px {{RIGHT}}px {{BOTTOM}}px {{LEFT}}px;',
				],
			],
			'qunatity_padding'          => [
				'label'      => esc_html__( 'Padding', 'shopbuilder' ),
				'type'       => 'dimensions',
				'size_units' => [ 'px', '%', 'em' ],
				'selectors'  => [
					self::$selectors['qunatity_padding'] => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				],
			],

			'quantity_section_end'      => [
				'mode' => 'section_end',
			],
		];
		return $fields;
	}

	/**
	 * Widget Field
	 *
	 * @return array
	 */
	public static function variation_style_fields() {
		$fields = [
			'variation_section'     => [
				'mode'  => 'section_start',
				'tab'   => 'style',
				'label' => esc_html__( 'Variations', 'shopbuilder' ),
			],
			'variation_padding'     => [
				'label'      => esc_html__( 'Padding', 'shopbuilder' ),
				'type'       => 'dimensions',
				'size_units' => [ 'px' ],
				'default'    => [
					'top'      => '10',
					'right'    => '10',
					'bottom'   => '10',
					'left'     => '10',
					'unit'     => 'px',
					'isLinked' => true,
				],
				'separator'  => 'default',
				'selectors'  => [
					self::$selectors['variation_padding'] => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				],
			],
			'variation_border'      => [
				'mode'     => 'group',
				'type'     => 'border',
				'label'    => esc_html__( 'Quantity Border', 'shopbuilder' ),
				'selector' => self::$selectors['variation_border'],
			],
			'variation_section_end' => [
				'mode' => 'section_end',
			],
		];
		return $fields;
	}


}

```
