Ecxlude category description from reload (Ajax pagination)
-
I like the ajax pagination feature of this plugin but how do I have the category/archive descriptions excluded from reloading on ajax pagination calls because returned descriptions loose some of their styling.
I also found that ajax pagination ignores some of the customizations I made using the code snippets plugin for example the change of add to cart text, addition of badges like out of stock and featured product label on archive pages.
-
Hello Iamlaurie,
Welcome back to our support forum!
The taxonomy archives adjustments and refreshes are controlled by the Archive pages support setting located in the annasta Filters > Product lists section of your WP admin. Try disabling it to see if this fixes the issue.
As for some CSS (?) adjustments not being visible in AJAX mode, this means that your custom CSS doesn’t cover the styling of the WooCommerce [products] shortcodes which are used for the plugin’s AJAX returns. This also occasionally happens with some themes, when their products lists CSS doesn’t cover the [products] shortcode, which brings disruption into the styling of AJAX returns.
You may be pleased to hear that we are currently working at a new option that will introduce the higher styling compatibility for AJAX calls returns. This new option will allow switching the AJAX returns to a compatibility mode, and may appear as early as the next plugin release planned to go out within a few weeks. It will be located in the annasta Filters > Product lists tab.
Thanks @annastaa,
The archive pages support setting has solved the issue of descriptions.
The other issue is not about CSS. Its rather PHP/HTML. These are the snippets which fail to work on ajax refresh pages
// To change button texts on archives add_filter( 'woocommerce_product_add_to_cart_text', function( $text ) { if ( 'Read more' == $text ) { $text = __( 'SOLD OUT', 'woocommerce' ); } if ( 'Select options' == $text ) { $text = __( 'SELECT OPTIONS', 'woocommerce' ); } if ( 'Add to cart' == $text ) { $text = __( 'BUY NOW', 'woocommerce' ); } return $text; } ); // To change Add to cart text on product page add_filter( 'woocommerce_product_single_add_to_cart_text', function( $text ) { if ( 'Add to cart' == $text ) { $text = __( 'BUY NOW', 'woocommerce' ); } return $text; } ); // BACK ORDERED PRODUCT ADD TO CART TEXT // To change add to cart text on single product page. add_filter( 'woocommerce_product_single_add_to_cart_text', 'backordered_custom_add_to_cart_text', 10, 2 ); // To change add to cart text on product archives (grid view) page. add_filter( 'woocommerce_product_add_to_cart_text', 'backordered_custom_add_to_cart_text', 10, 2 ); function backordered_custom_add_to_cart_text( $text, $product ) { if ( $product->is_on_backorder( 1 ) ) { $text = __( 'PRE-ORDER', 'woocommerce' ); } return $text; }function wc_varb_price_range( $wcv_price, $product ) { $prefix = sprintf('%s: ', __('From', 'wcvp_range')); $wcv_reg_min_price = $product->get_variation_regular_price( 'min', true ); $wcv_min_sale_price = $product->get_variation_sale_price( 'min', true ); $wcv_max_price = $product->get_variation_price( 'max', true ); $wcv_min_price = $product->get_variation_price( 'min', true ); $wcv_price = ( $wcv_min_sale_price == $wcv_reg_min_price ) ? wc_price( $wcv_reg_min_price ) : '<del>' . wc_price( $wcv_reg_min_price ) . '</del>' . '<ins>' . wc_price( $wcv_min_sale_price ) . '</ins>'; return ( $wcv_min_price == $wcv_max_price ) ? $wcv_price : sprintf('%s%s', $prefix, $wcv_price); } add_filter( 'woocommerce_variable_sale_price_html', 'wc_varb_price_range', 10, 2 ); add_filter( 'woocommerce_variable_price_html', 'wc_varb_price_range', 10, 2 );add_action( 'woocommerce_before_shop_loop_item_title', 'bbloomer_new_badge_shop_page', 3 ); function bbloomer_new_badge_shop_page() { global $product; $newness_days = 30; $created = strtotime( $product->get_date_created() ); if ( ( time() - ( 60 * 60 * 24 * $newness_days ) ) < $created ) { echo '<span class="newarrival">' . esc_html__( 'NEW', 'woocommerce' ) . '</span>'; } }add_action( 'woocommerce_before_shop_loop_item_title', 'bbloomer_display_sold_out_loop_woocommerce' ); function bbloomer_display_sold_out_loop_woocommerce() { global $product; if ( !$product->is_in_stock() ) { echo '<span class="soldout">' . __( 'OUT OF STOCK', 'woocommerce' ) . '</span>'; } }//Show backorder badge on archive pages add_action( 'woocommerce_before_shop_loop_item_title', 'bbloomer_display_on_backorder_loop_woocommerce' ); function bbloomer_display_on_backorder_loop_woocommerce() { global $product; if ( $product->is_on_backorder() ) { echo '<span class="onbackorder">' . __( 'COMING SOON', 'woocommerce' ) . '</span>'; } }add_action( 'woocommerce_before_shop_loop_item_title', 'bbloomer_display_featured_loop_woocommerce' ); function bbloomer_display_featured_loop_woocommerce() { global $product; if ( $product->is_featured() ) { echo '<span class="isfeatured">' . __( 'Clearance', 'woocommerce' ) . '</span>'; } }I inserted the above using the code snippets plugin. The ajax refresh pages are returning woocommerce defaults. But the styling is OK
Iamlaurie, this is a very interesting observation,
I have just tested some of your custom hooks on our test site running the Storefront theme, and they work as expected, AJAX or not! This is probably due to your theme re-wiring all the native WooCommerce hooks related to products lists.
In any case, I believe that there is no point in offering to debug this, because the upcoming AJAX compatibility mode option that I referred to in my last post will most likely resolve all the issues of this nature. The new release is tentatively planned to go out by the end of next week, so please wait for it if you wish to test the compatibility mode. You can temporarily set your preset’s Filtering style to URL filters to bypass the custom hooks issue.
Dear Iamlaurie,
You are now welcome to test the Enhanced compatibility AJAX mode introduced by the new (1.6.0) version of the plugin!
I will mark the thread as resolved, but please unmark it (or create a new topic) if you find that you face the same issues with your custom hooks even after enabling the compatibility mode.
The topic ‘Ecxlude category description from reload (Ajax pagination)’ is closed to new replies.