Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #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,
    Pter

    #633562

    Hey 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,
    Ismael

    #633585

    Hi 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,
    Peter

    #633610

    I 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
    Peter

    #634867

    Hi,

    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,
    Ismael

    #635052

    Amazing! :) 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,
    Peter

    #635694

    Hi,

    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,
    Ismael

    #635816

    OH MY GOD! You’re the best support team in the universe of wordpress themes!!
    :D

    Best Regards,
    Peter

    #636129

    Hey!

    Glad it worked. Let us know if you need anything else. :D

    Regards,
    Ismael

Viewing 9 posts - 1 through 9 (of 9 total)
  • The topic ‘woocommerce avia product slider 'on sale' filter’ is closed to new replies.