PluginProbe
ShopBuilder – WooCommerce Builder For Elementor / 2.6.5
ShopBuilder – WooCommerce Builder For Elementor v2.6.5
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
← All changes | app/Controllers/Hooks/ActionHooks.php +137 -17 2.1.112.6.5 View file →
@@ -6,8 +6,9 @@
6 6 */
7 7
8 8 namespace RadiusTheme\SB\Controllers\Hooks;
9 9
10 +use RadiusTheme\SB\Elementor\Helper\RenderHelpers;
10 11 use RadiusTheme\SB\Helpers\Fns;
11 12 use RadiusTheme\SB\Models\GeneralList;
12 13 use RadiusTheme\SB\Helpers\BuilderFns;
13 14 use RadiusTheme\SB\Models\TemplateSettings;
@@ -81,8 +82,17 @@
81 82 add_action( 'woocommerce_before_checkout_form', [ __CLASS__, 'woocommerce_checkout_coupon_form' ], 10 );
82 83 // My Account Order Page.
83 84 add_action( 'woocommerce_before_account_orders', [ __CLASS__, 'before_account_orders' ], 10 );
84 85 add_action( 'woocommerce_after_account_orders', [ __CLASS__, 'after_account_orders' ], 10 );
86 +
87 + // Product Filter Widget Hooks.
88 + add_action( 'rtsb/before/archive/default/filter/items', [ __CLASS__,'default_filter_header' ], 10 );
89 + add_action( 'rtsb/before/archive/default/filter/items', [ __CLASS__,'default_filter_search' ], 15 );
90 +
91 + // WC Query modifier.
92 + if ( ! rtsb()->has_pro() ) {
93 + add_action( 'woocommerce_product_query', [ __CLASS__, 'query_modifier' ], 15 );
94 + }
85 95 }
86 96
87 97
88 98 /**
@@ -112,9 +122,9 @@
112 122 * @return void
113 123 */
114 124 public static function woocommerce_checkout_coupon_form() {
115 125 echo '<div class="rtsb-notice">';
116 - woocommerce_checkout_coupon_form();
126 + woocommerce_checkout_coupon_form();
117 127 echo '</div>';
118 128 }
119 129
120 130 /**
@@ -134,9 +144,8 @@
134 144 wc_empty_cart_message();
135 145 echo '</div>';
136 146 }
137 147
138 -
139 148 /**
140 149 * @param int $post_id Post Ids.
141 150 * @param object $post Post Object.
142 151 *
@@ -145,34 +154,57 @@
145 154 public static function deleted_post( $post_id, $post ) {
146 155 if ( BuilderFns::$post_type_tb !== $post->post_type ) {
147 156 return;
148 157 }
158 +
149 159 $options = BuilderFns::option_name_for_specific_product_set_default( $post_id );
160 + TemplateSettings::instance()->delete_option( $options );
150 161
151 - if ( TemplateSettings::instance()->get_option( $options ) ) {
152 - TemplateSettings::instance()->delete_option( $options );
153 - }
154 -
155 162 $template_options = BuilderFns::option_name_by_template_id( $post_id );
156 - if ( TemplateSettings::instance()->get_option( $template_options ) ) {
157 - TemplateSettings::instance()->delete_option( $template_options );
158 - }
163 + TemplateSettings::instance()->delete_option( $template_options );
159 164
160 165 $archive_options = BuilderFns::archive_option_name_by_template_id( $post_id );
161 - if ( TemplateSettings::instance()->get_option( $archive_options ) ) {
162 - TemplateSettings::instance()->delete_option( $archive_options );
163 - }
166 + TemplateSettings::instance()->delete_option( $archive_options );
164 167
165 168 $category_options = BuilderFns::option_name_for_specific_category_set_default( $post_id );
166 - if ( TemplateSettings::instance()->get_option( $category_options ) ) {
167 - TemplateSettings::instance()->delete_option( $category_options );
169 + TemplateSettings::instance()->delete_option( $category_options );
170 +
171 + $selected_category_options = BuilderFns::archive_option_name_by_template_id( $post_id );
172 + TemplateSettings::instance()->delete_option( $selected_category_options );
173 +
174 + // Delete Data From Options.
175 + $options_product_selected_cat = BuilderFns::option_name_product_page_selected_cat( $post_id );
176 + $cat_list = TemplateSettings::instance()->get_option( $options_product_selected_cat );
177 + if ( ! empty( $cat_list ) ) {
178 + foreach ( $cat_list as $old_slug ) {
179 + $OldcatList = get_term_by( 'slug', $old_slug, 'product_cat' );
180 + if ( ! empty( $OldcatList ) && ! is_wp_error( $OldcatList ) ) {
181 + delete_term_meta( $OldcatList->term_id, BuilderFns::$categories_product_page_template, $post_id );
182 + }
183 + }
168 184 }
185 + TemplateSettings::instance()->delete_option( $options_product_selected_cat );
169 186
170 - $selected_category_options = BuilderFns::archive_option_name_by_template_id( $post_id );
171 - if ( TemplateSettings::instance()->get_option( $selected_category_options ) ) {
172 - TemplateSettings::instance()->delete_option( $selected_category_options );
187 + $set_default_option = BuilderFns::option_name_product_page_specific_cat_set_default( $post_id );
188 + TemplateSettings::instance()->delete_option( $set_default_option );
189 +
190 + // Tags Remove.
191 + $options_product_selected_tag = BuilderFns::option_name_product_page_selected_tag( $post_id );
192 + $tag_list = TemplateSettings::instance()->get_option( $options_product_selected_tag );
193 + if ( ! empty( $tag_list ) ) {
194 + foreach ( $tag_list as $old_slug ) {
195 + $OldTagList = get_term_by( 'slug', $old_slug, 'product_tag' );
196 + if ( ! empty( $OldTagList ) && ! is_wp_error( $OldTagList ) ) {
197 + delete_term_meta( $OldTagList->term_id, BuilderFns::$tags_product_page_template, $post_id );
198 + }
199 + }
173 200 }
201 + TemplateSettings::instance()->delete_option( $options_product_selected_tag );
174 202
203 + // Tag Set Default Option.
204 + $tag_set_default_option = BuilderFns::option_name_product_page_specific_tag_set_default( $post_id );
205 + TemplateSettings::instance()->delete_option( $tag_set_default_option );
206 +
175 207 global $wpdb;
176 208 // Prepare and execute the SQL query.
177 209 $sql = $wpdb->prepare( "DELETE FROM $wpdb->postmeta WHERE meta_key = %s AND meta_value = %d", BuilderFns::$view_template_for_products_meta, $post_id );
178 210 $wpdb->query( $sql ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.DirectDatabaseQuery.NoCaching
@@ -308,6 +340,94 @@
308 340
309 341 if ( 'yes' === get_option( 'woocommerce_hide_out_of_stock_items' ) ) {
310 342 remove_filter( 'woocommerce_product_data_store_cpt_get_products_query', [ FilterHooks::class, 'extra_query_args_outofstock' ] );
311 343 }
344 + }
345 + /**
346 + * Display a filter header.
347 + *
348 + * @param array $settings The settings.
349 + *
350 + * @return void
351 + */
352 + public static function default_filter_header( $settings ) {
353 + if ( empty( $settings['show_filter_header'] ) && empty( $settings['filter_header_text'] ) ) {
354 + return;
355 + }
356 +
357 + $wrapper_class = 'rtsb-default-filter-header ';
358 +
359 + ?>
360 +
361 + <div class="<?php echo esc_attr( $wrapper_class ); ?>">
362 + <h3><?php echo esc_html( $settings['filter_header_text'] ); ?></h3>
363 + </div>
364 +
365 + <?php
366 + }
367 + /**
368 + * Display a filter search form.
369 + *
370 + * @param array $settings The settings.
371 + *
372 + * @return void
373 + */
374 + public static function default_filter_search( $settings ) {
375 + if ( empty( $settings['search_form'] ) ) {
376 + return;
377 + }
378 +
379 + $title = [
380 + 'title' => ! empty( $settings['search_title'] ) ? $settings['search_title'] : '',
381 + 'show_icon' => ! empty( $settings['show_search_title_icon'] ),
382 + 'icon' => ! empty( $settings['filter_search_title_icon'] ) ? $settings['filter_search_title_icon'] : [],
383 + ];
384 + $placeholder = ! empty( $settings['search_placeholder'] ) ? $settings['search_placeholder'] : '';
385 + $btn_icon = ! empty( $settings['search_title_icon'] ) ? $settings['search_title_icon'] : [];
386 + $wrapper_class = 'rtsb-default-filter-search rtsb-default-product-search';
387 + $unique_id = substr( uniqid(), -6 );
388 + $search_term = isset( $_REQUEST['s'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['s'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
389 + ?>
390 +
391 + <div class="<?php echo esc_attr( $wrapper_class ); ?>">
392 + <?php
393 + Fns::print_html( RenderHelpers::get_default_filter_title( $title ) );
394 + ?>
395 + <div class="default-search-content">
396 + <div class="woocommerce-product-search<?php echo ! empty( $search_term ) ? ' active' : ''; ?>">
397 + <div class="search-input">
398 + <label class="screen-reader-text" for="rtsb-product-default-search-form-<?php echo esc_attr( $unique_id ); ?>"><?php echo esc_html( $placeholder ); ?></label>
399 + <input type="search" id="rtsb-product-default-search-form-<?php echo esc_attr( $unique_id ); ?>" class="rtsb-default-search-field" placeholder="<?php echo esc_html( $placeholder ); ?>" value="<?php echo esc_attr( $search_term ); ?>" name="s" autocomplete="off">
400 + </div>
401 + <button class="rtsb-search-submit">
402 + <?php
403 +
404 + Fns::print_html( Fns::icons_manager( $btn_icon, 'search-icon' ) );
405 +
406 + ?>
407 + <span></span>
408 + </button>
409 + </div>
410 + </div>
411 + </div>
412 +
413 + <?php
414 + }
415 + /**
416 + * Query modifier.
417 + *
418 + * @param object $query Query.
419 + * @return object
420 + */
421 + public static function query_modifier( $query ) {
422 + $onsale_filter = isset( $_GET['sale_filter'] ) ? sanitize_text_field( wp_unslash( $_GET['sale_filter'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
423 + $on_sale_products = wc_get_product_ids_on_sale();
424 +
425 + if ( 'onsale' === $onsale_filter ) {
426 + $query->set( 'post__in', ! empty( $on_sale_products ) ? $on_sale_products : [ 0 ] );
427 + } elseif ( 'regular' === $onsale_filter ) {
428 + $query->set( 'post__not_in', $on_sale_products );
429 + }
430 +
431 + return $query;
312 432 }
313 433 }