PluginProbe
ShopBuilder – WooCommerce Builder For Elementor / 2.1.7
ShopBuilder – WooCommerce Builder For Elementor v2.1.7
3.4.2 3.4.1 3.4.0 2.0.1 2.0.2 2.0.3 2.1.0 2.1.1 2.1.10 2.1.11 2.1.12 2.1.13 2.1.14 2.1.15 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 2.2.0 2.2.1 2.2.2 All 63 releases
shopbuilder / app / Elementor / Widgets / Single / ProductAddToCart.php

ProductAddToCart.php in ShopBuilder – WooCommerce Builder For Elementor 2.1.7, at app/Elementor/Widgets/Single/ProductAddToCart.php

208 lines 5.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Main ProductDescription class.
4 *
5 * @package RadiusTheme\SB
6 */
7
8 namespace RadiusTheme\SB\Elementor\Widgets\Single;
9
10 use RadiusTheme\SB\Helpers\Fns;
11 use RadiusTheme\SB\Abstracts\ElementorWidgetBase;
12 use RadiusTheme\SB\Elementor\Widgets\Controls\AddToCartSettings;
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 ProductAddToCart extends ElementorWidgetBase {
23 /**
24 * Construct function
25 *
26 * @param array $data default array.
27 * @param mixed $args default arg.
28 */
29 public function __construct( $data = [], $args = null ) {
30 $this->rtsb_name = esc_html__( 'Product add to cart', 'shopbuilder' );
31 $this->rtsb_base = 'rtsb-product-add-to-cart';
32 parent::__construct( $data, $args );
33 }
34 /**
35 * Widget Field
36 *
37 * @return array
38 */
39 public function widget_fields() {
40 return AddToCartSettings::widget_fields( $this );
41 }
42 /**
43 * Set Widget Keyword.
44 *
45 * @return array
46 */
47 public function get_keywords() {
48 return [ 'Cart' ] + parent::get_keywords();
49 }
50 /**
51 * Widget Field.
52 *
53 * @param array $controllers Control.
54 *
55 * @return void
56 */
57 public function the_hooks( $controllers = null ) {
58 if ( ! $controllers ) {
59 return;
60 }
61
62 if ( ! empty( $controllers['quantity_style'] ) ) {
63 if ( in_array( $controllers['quantity_style'], [ 'style-1', 'style-2' ] ) ) {
64 add_action(
65 'woocommerce_before_quantity_input_field',
66 function () use ( $controllers ) {
67 ?>
68 <!-- Quantity Wrapper Start -->
69 <div class="rtsb-quantity-box-group rtsb-quantity-box-group-<?php echo esc_attr( $controllers['quantity_style'] ); ?>">
70 <button type="button" class="rtsb-quantity-btn rtsb-quantity-minus">
71 <?php
72 echo wp_kses(
73 $controllers['decrement_icon_html'],
74 [
75 'i' => [
76 'class' => [],
77 'aria-hidden' => [],
78 ],
79 ]
80 );
81 ?>
82 </button>
83 <?php
84 }
85 );
86 add_action(
87 'woocommerce_after_quantity_input_field',
88 function () use ( $controllers ) {
89 ?>
90 <button type="button" class="rtsb-quantity-btn rtsb-quantity-plus">
91 <?php
92 echo wp_kses(
93 $controllers['increment_icon_html'],
94 [
95 'i' => [
96 'class' => [],
97 'aria-hidden' => [],
98 ],
99 ]
100 );
101 ?>
102 </button>
103 </div>
104 <!-- Quantity Wrapper End -->
105 <?php
106 }
107 );
108 }
109 if ( in_array( $controllers['quantity_style'], [ 'style-3', 'style-4' ] ) ) {
110 add_action(
111 'woocommerce_before_quantity_input_field',
112 function () use ( $controllers ) {
113 $inner_border = ! empty( $controllers['show_inner_border'] ) ? 'show-inner-border' : '';
114 ?>
115 <!-- Quantity Wrapper Start -->
116 <div class="rtsb-quantity-box-group rtsb-quantity-box-group-<?php echo esc_attr( $controllers['quantity_style'] . ' ' . $inner_border ); ?>">
117 <div class="rtsb-qty-btns-group">
118 <button type="button" class="rtsb-quantity-btn rtsb-quantity-plus">
119 <?php
120 echo wp_kses(
121 $controllers['increment_icon_html'],
122 [
123 'i' => [
124 'class' => [],
125 'aria-hidden' => [],
126 ],
127 ]
128 );
129 ?>
130 </button>
131 <button type="button" class="rtsb-quantity-btn rtsb-quantity-minus">
132 <?php
133 echo wp_kses(
134 $controllers['decrement_icon_html'],
135 [
136 'i' => [
137 'class' => [],
138 'aria-hidden' => [],
139 ],
140 ]
141 );
142 ?>
143 </button>
144 </div>
145 <?php
146 }
147 );
148 add_action(
149 'woocommerce_after_quantity_input_field',
150 function () {
151 ?>
152 </div>
153 <!-- Quantity Wrapper End -->
154 <?php
155 }
156 );
157 }
158 }
159
160 if ( $this->is_edit_mode() ) {
161 if ( class_exists( Rtwpvs\Controllers\Hooks::class ) ) {
162 remove_filter( 'woocommerce_ajax_variationX_threshold', [ Rtwpvs\Controllers\Hooks::class, 'ajax_variation_threshold' ], 99 );
163 }
164
165 add_filter(
166 'woocommerce_ajax_variation_threshold',
167 function () {
168 return 1;
169 },
170 99
171 );
172
173 }
174 }
175 /**
176 * Render Function
177 *
178 * @return void
179 */
180 protected function render() {
181 global $product;
182 $_product = $product;
183 $product = Fns::get_product();
184 $controllers = $this->get_settings_for_display();
185 $controllers['increment_icon_html'] = Fns::icons_manager( $controllers['increment_icon'] );
186 $controllers['decrement_icon_html'] = Fns::icons_manager( $controllers['decrement_icon'] );
187 $controllers['cart_icon_html'] = Fns::icons_manager( $controllers['cart_icon'] );
188 $add_to_cart_visibility = rtsb()->has_pro() && Fns::is_guest_feature_disabled( 'hide_add_to_cart', '' );
189 $controllers['visibility'] = $add_to_cart_visibility ? ' rtsb-not-visible' : ' rtsb-is-visible';
190
191 $this->the_hooks( $controllers );
192 $this->theme_support();
193
194 $data = [
195 'template' => 'elementor/single-product/add-to-cart',
196 'controllers' => $controllers,
197 'product_type' => $product ? $product->get_type() : '',
198 ];
199
200 Fns::load_template( $data['template'], $data );
201
202 $this->editor_cart_icon_script();
203 $this->theme_support( 'render_reset' );
204
205 $product = $_product; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
206 }
207 }
208