Tagged: product slider, woocommerce
-
AuthorPosts
-
May 15, 2016 at 9:31 pm #632583
Hello,
I would like to select just the ‘on sale’ products on the avia product slider not category.
Could you help me?Thank you
Best regards,
PterMay 17, 2016 at 9:08 am #633562Hey jambrikp,
Thank you for using Enfold.
There is no option for that in the Product Slider element so a workaround is to add an “onsale” category to the products that are currently on sale.
Best regards,
IsmaelMay 17, 2016 at 9:49 am #633585Hi Ismael,
What do you think, possible an auto generated and dynamic onsale category in Woo?
Good idea to add this feature to “feature request”? Or this feature will not have much interest for other users?Best regards,
PeterMay 17, 2016 at 10:50 am #633610I found a code which returns an array containing the IDs of the products that are on sale. This lets them use a simple query to get the sale products:
$query_args = array( 'posts_per_page' => 8, 'no_found_rows' => 1, 'post_status' => 'publish', 'post_type' => 'product', 'meta_query' => WC()->query->get_meta_query(), 'post__in' => array_merge( array( 0 ), wc_get_product_ids_on_sale() ) ); $products = new WP_Query( $query_args );
https://www.skyverge.com/blog/get-a-list-of-woocommerce-sale-products/
I would like a feature what is just a checkbox on the avia product slider. This checkbox is a filter for ‘onsale’ products. So I can choose one or more category or all category and If I tick the ‘onsale’ checkbox, the slider show only the ‘onsale’ products from the selected category.
What do you think?
Best regards
PeterMay 19, 2016 at 3:27 am #634867Hi,
I see. Thanks for the info. This might work:
add_filter('avia_product_slide_query', 'avia_product_slide_query_mod', 10, 1); function avia_product_slide_query_mod($params) { $query_args = array( 'no_found_rows' => 1, 'meta_query' => WC()->query->get_meta_query(), 'post__in' => array_merge( array( 0 ), wc_get_product_ids_on_sale() ) ); $params = array_merge($query_args, $params); return $params; }
Add the is_page conditional if you want this code to be applied to a specific page only.
Best regards,
IsmaelMay 19, 2016 at 9:01 am #635052Amazing! :) Its work, thank you!
How can I use this code on a specific slider only? Each product slider has a unique class: avia-content-slider1, avia-content-slider2.. etc
But its not an #ID…Best regards,
PeterMay 20, 2016 at 5:18 am #635694Hi,
Try to replace the code with the following:
add_filter('avia_product_slide_query', 'avia_product_slide_query_mod', 10, 2); function avia_product_slide_query_mod($params, $grid, $test) { $query_args = array(); if( avia_post_slider::$slide == 0) { $query_args['no_found_rows'] = 1; $query_args['meta_query'] = WC()->query->get_meta_query(); $query_args['post__in'] = array_merge( array( 0 ), wc_get_product_ids_on_sale() ); } $params = array_merge($query_args, $params); return $params; }
The “avia_post_slider::$slide == 0” refers to the first product slider. Setting the value to 1 will affect the second product slider and so on, so forth.
Best regards,
IsmaelMay 20, 2016 at 10:39 am #635816OH MY GOD! You’re the best support team in the universe of wordpress themes!!
:DBest Regards,
PeterMay 21, 2016 at 5:00 am #636129 -
AuthorPosts
- The topic ‘woocommerce avia product slider 'on sale' filter’ is closed to new replies.