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 / Controllers / ThemesSupport / Astra / WidgetsSupport.php

WidgetsSupport.php in ShopBuilder – WooCommerce Builder For Elementor 2.1.7, at app/Controllers/ThemesSupport/Astra/WidgetsSupport.php

340 lines 9.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Main ProductDescription class.
5 *
6 * @package RadiusTheme\SB
7 */
8
9 namespace RadiusTheme\SB\Controllers\ThemesSupport\Astra;
10
11 // Do not allow directly accessing this file.
12 use Rtwpvsp\Controllers\ShopPage;
13
14 if ( ! defined( 'ABSPATH' ) ) {
15 exit( 'This script cannot be accessed directly.' );
16 }
17
18 /**
19 * Product Description class
20 */
21 class WidgetsSupport {
22
23 /**
24 * The single instance of the class.
25 *
26 * @var object
27 */
28 protected static $instance = null;
29
30 /**
31 * The single instance of the class.
32 *
33 * @var object
34 */
35 private $widgets;
36
37 /**
38 * Construct function
39 */
40 private function __construct() {
41 }
42
43 /**
44 * Get class instance.
45 *
46 * @return object Instance.
47 */
48 public static function instance( $widgets ) {
49 if ( ! self::$instance ) {
50 self::$instance = new self();
51 }
52 self::$instance->widgets = $widgets;
53
54 return self::$instance;
55 }
56
57 /**
58 * @param $html
59 *
60 * @return string
61 */
62 public function astra_flash_sale_html_remove( $html ) {
63 return '';
64 }
65
66 /**
67 * Astra Wrapper
68 *
69 * @return void
70 */
71 public function astra_woo_shop_thumbnail_wrap_start() {
72 echo '<div class="astra-shop-thumbnail-wrap rtsb-image-wrapper">';
73 }
74
75 /**
76 * Product Loop content Modify.
77 *
78 * @return void
79 */
80 public function astra_product_loop() {
81 $controllers = $this->widgets->get_settings_for_display();
82
83 if ( ! apply_filters( 'astra_woo_shop_product_structure_override', false ) ) {
84 // Remove some hooks.
85 remove_action( 'woocommerce_before_shop_loop_item', 'astra_woo_shop_thumbnail_wrap_start', 6 );
86 remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_rating', 5 );
87 remove_action( 'woocommerce_shop_loop_item_title', 'woocommerce_template_loop_product_title', 10 );
88 remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 10 );
89 remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 );
90
91 // Adding some hooks.
92 add_action( 'woocommerce_before_shop_loop_item', [ $this, 'astra_woo_shop_thumbnail_wrap_start' ], 6 );
93 add_action( 'woocommerce_after_shop_loop_item', 'astra_woo_shop_thumbnail_wrap_end', 8 );
94 add_action( 'woocommerce_after_shop_loop_item', 'astra_woo_woocommerce_shop_product_content' );
95 add_action( 'astra_woo_shop_before_summary_wrap', [ $this->widgets, 'product_content_wrapper' ], 6 );
96 add_action( 'astra_woo_shop_after_summary_wrap', [ $this->widgets, 'div_close' ], 6 );
97
98 if ( empty( $controllers['show_flash_sale'] ) ) {
99 if ( ! defined( 'ASTRA_EXT_VER' ) || ( defined( 'ASTRA_EXT_VER' ) && ! \Astra_Ext_Extension::is_active( 'woocommerce' ) ) ) {
100 add_filter( 'astra_addon_shop_cards_buttons_html', [ $this, 'astra_flash_sale_html_remove' ] );
101 }
102 }
103
104 }
105 $this->widgets->apply_hooks_set_default();
106
107 // Variation Swatch fix
108 if ( class_exists( 'WooProductVariationSwatches' ) ) {
109 $swatches_position = rtwpvs()->get_option( 'archive_swatches_position' );
110 if ( 'before_title_and_price' == $swatches_position && class_exists( ShopPage::class ) ) {
111 remove_action( 'woocommerce_before_shop_loop_item_title', [
112 ShopPage::class,
113 'archive_variation_swatches',
114 ], 35 );
115 add_action( 'astra_woo_shop_title_before', [
116 ShopPage::class,
117 'archive_variation_swatches',
118 ], 35 );
119 }
120
121 }
122
123 // Remove Action Button.
124 add_filter( 'rtsb/module/wishlist/show_button', '__return_false' );
125 add_filter( 'rtsb/module/quick_view/show_button', '__return_false' );
126 add_filter( 'rtsb/module/compare/show_button', '__return_false' );
127
128 }
129
130 /**
131 * Product Content Reset.
132 *
133 * @return void
134 */
135 public function astra_product_loop_reset_default() {
136 $controllers = $this->widgets->get_settings_for_display();
137
138 if ( ! apply_filters( 'astra_woo_shop_product_structure_override', false ) ) {
139 // Remove Product Content Wrapper.
140 remove_action( 'astra_woo_shop_before_summary_wrap', [ $this->widgets, 'product_content_wrapper' ], 6 );
141 remove_action( 'astra_woo_shop_after_summary_wrap', [ $this->widgets, 'div_close' ], 6 );
142 if ( empty( $controllers['show_flash_sale'] ) ) {
143 if ( ! defined( 'ASTRA_EXT_VER' ) || ( defined( 'ASTRA_EXT_VER' ) && ! \Astra_Ext_Extension::is_active( 'woocommerce' ) ) ) {
144 remove_filter( 'astra_addon_shop_cards_buttons_html', [ $this, 'astra_flash_sale_html_remove' ] );
145 }
146 }
147 }
148 }
149
150 /**
151 * The function name comes from the widget base name "rtsb-products-archive". This is for theme support prefix with render.
152 *
153 * @return void
154 */
155 public function render_rtsb_products_archive() {
156 $this->astra_product_loop();
157 }
158
159 /**
160 * .
161 *
162 * @return void
163 */
164 public function render_reset_rtsb_products_archive() {
165 $this->astra_product_loop_reset_default();
166 }
167
168 /**
169 * The function name comes from the widget base name "rtsb-products-archive". This is for theme support prefix with render.
170 *
171 * @return void
172 */
173 public function render_rtsb_upsells_product() {
174 $this->astra_product_loop();
175 }
176
177 /**
178 * Reset Hooks.
179 *
180 * @return void
181 */
182 public function render_reset_rtsb_upsells_product() {
183 $this->astra_product_loop_reset_default();
184 }
185
186 /**
187 * Related Product.
188 *
189 * @return void
190 */
191 public function render_rtsb_related_product() {
192 $this->astra_product_loop();
193 }
194
195 /**
196 * Related Product.
197 *
198 * @return void
199 */
200 public function render_reset_rtsb_related_product() {
201 $this->astra_product_loop_reset_default();
202 }
203
204 /**
205 * Cross Sell Product.
206 *
207 * @return void
208 */
209 public function render_rtsb_cross_sells() {
210 $this->astra_product_loop();
211 }
212
213 /**
214 * Cross Sell Product.
215 *
216 * @return void
217 */
218 public function render_reset_rtsb_cross_sells() {
219 $this->astra_product_loop_reset_default();
220 }
221
222 /**
223 * Cross Sell Product.
224 *
225 * @return void
226 */
227 public function render_rtsb_product_onsale() {
228 add_filter( 'woocommerce_sale_flash', array( \Astra_Woocommerce::get_instance(), 'get_sale_flash_markup' ), 10, 3 );
229 }
230 /**
231 * Cross Sell Product.
232 *
233 * @return void
234 */
235 public function render_rtsb_product_stock() {
236 remove_filter( 'woocommerce_get_stock_html', 'astra_woo_product_in_stock', 10, 2 );
237 }
238
239 /**
240 * The function name comes from the widget base name "rtsb-products-archive". This is for theme support prefix with widget_controls.
241 *
242 * @return void
243 */
244 public function widget_controls_rtsb_product_tabs() {
245 add_filter( 'rtsb/elements/elementor/widgets/controls/rtsb-product-tabs', [ $this, 'product_tabs_widget_controls_support' ] );
246 }
247
248 /**
249 * Widget Field.
250 *
251 * @return array
252 */
253 public function product_tabs_widget_controls_support( $fields ) {
254 $fields['nav_active_border_color']['selectors'] = array_merge(
255 $fields['nav_active_border_color']['selectors'],
256 [
257 '{{WRAPPER}} .woocommerce-tabs ul.tabs li.active:before' => 'background: {{VALUE}}',
258 ]
259 );
260 $fields['nav_active_hover_border_color']['selectors'] = array_merge(
261 $fields['nav_active_hover_border_color']['selectors'],
262 [
263 '{{WRAPPER}} .woocommerce-tabs ul.tabs li.active:hover:before' => 'background: {{VALUE}}',
264 ]
265 );
266
267 return $fields;
268 }
269
270 /**
271 * The function name comes from the widget base name "rtsb-products-archive". This is for theme support prefix with "widget_controls".
272 *
273 * @return void
274 */
275 public function widget_controls_rtsb_products_archive() {
276 add_filter( 'rtsb/elements/elementor/widgets/controls/rtsb-products-archive', [ $this, 'product_loop_widget_controls_support' ], 11 );
277 }
278
279 /**
280 * Widget Field.
281 *
282 * @return array
283 */
284 public function product_loop_widget_controls_support( $fields ) {
285 if ( $this->widgets->has_pagination ) {
286 $fields['prev_icon']['default'] = [
287 'value' => 'fas fa-long-arrow-alt-left',
288 'library' => 'fa-solid',
289 ];
290 $fields['next_icon']['default'] = [
291 'value' => 'fas fa-long-arrow-alt-right',
292 'library' => 'fa-solid',
293 ];
294 }
295
296 return $fields;
297 }
298
299 /**
300 * The function name comes from the widget base name "rtsb-products-archive". This is for theme support prefix with widget_controls.
301 *
302 * @return void
303 */
304 public function widget_controls_rtsb_related_product() {
305 add_filter( 'rtsb/elements/elementor/widgets/controls/rtsb-related-product', [ $this, 'widget_controls_flash_sale' ] );
306 }
307
308 /**
309 * @return void
310 */
311 public function widget_controls_rtsb_upsells_product() {
312 add_filter( 'rtsb/elements/elementor/widgets/controls/rtsb-upsells-product', [ $this, 'widget_controls_flash_sale' ] );
313 }
314 /**
315 * @return void
316 */
317 public function widget_controls_rtsb_cross_sells() {
318 add_filter( 'rtsb/elements/elementor/widgets/controls/rtsb-cross-sells', [ $this, 'widget_controls_flash_sale' ] );
319 }
320 /**
321 * Widget Field.
322 *
323 * @return array
324 */
325 public function widget_controls_flash_sale( $fields ) {
326 $selector = '{{WRAPPER}} .products .product .ast-onsale-card';
327 $fields['flash_sale_typography']['selector'] = $selector;
328 $fields['product_flash_sale_color']['selectors'][ $selector ] = 'color: {{VALUE}};';
329 $fields['flash_sale_bg_color']['selectors'][ $selector ] = 'background-color: {{VALUE}};';
330 $fields['flash_sale_badge_width']['selectors'][ $selector ] = 'width: {{SIZE}}{{UNIT}};display:flex; justify-content: center;';
331 $fields['flash_sale_badge_height']['selectors'][ $selector ] = 'height: {{SIZE}}{{UNIT}};align-items:center;';
332 $fields['flash_sale_badge_border_radius']['selectors'][ $selector ] = 'border-radius: {{SIZE}}{{UNIT}};';
333
334 return $fields;
335 }
336
337
338 }
339
340