PluginProbe
ShopBuilder – WooCommerce Builder For Elementor / 2.1.3
ShopBuilder – WooCommerce Builder For Elementor v2.1.3
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.3, at app/Elementor/Widgets/Single/ProductAddToCart.php

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