• Resolved paulfwp

    (@paulfwp)


    Hello,

    I am trying to display the discounted products on my sale page, the sale page is simply a filter on the woocommerce_product_query hook.

    Woocommerce has a function which returns all the product ID’s that are on sale. I’ve tried to loop through all the products with the advanced_woo_discount_rules_get_product_discount_price_from_custom_price filter (see bottom), but that results in a 500 error.

    function bd_change_product_query( $q ){
    	if($_GET['filter'] == 'sale'){
    		$id_s = wc_get_product_ids_on_sale();
    		
    		$q->set( 'post__in', (array) $id_s );
    	}
    
    }
    add_action( 'woocommerce_product_query', 'bd_change_product_query' );

    Looping through all products:

    $args     = array( 'post_type' => 'product', 'posts_per_page' => -1 );
    $products = get_posts( $args ); 
    foreach($products as $p){
    
    $discounted_price = apply_filters('advanced_woo_discount_rules_get_product_discount_price_from_custom_price', false, $product, 1, 0, 'all', true);
    $wooco_discounted_price = $product->get_sale_price();
    
    if ($discounted_price !== false) {
        if ($discounted_price['discounted_price']  > 0) { 
            // woo discount rule, here I want to push the ID to a array
        } elseif ($wooco_discounted_price > 0) {
            // woocommerce discount
        }
    }
    }
Viewing 3 replies - 1 through 3 (of 3 total)
  • sangeethasrinivasan

    (@sangeethasrinivasan)

    Hi,
    Thank you for reaching out.

    Using Discount Rules for Woocommerce plugin, it is possible to create a separate sale page.

    Let’s say, your shop has 50 products and you have set a specific product discount to only 10 products.?You can list out the 10 products on a separate page so that the customers can right away shop the products that have discounts.

    Here is a guide which helps you to create a sale page:
    https://docs.flycart.org/en/articles/4098969-sale-page-discount-rules-2-0

    Are you trying to get discounted products via our plugin ?

    Can you please open a support ticket here –> https://www.flycart.org/support by elaborating requirement and screenshots indicating the same, so that we can quickly check and assist accordingly?

    Thanks
    Team Flycart

    Thread Starter paulfwp

    (@paulfwp)

    Hi, I wanted to combine the sales products of this plugin with other normal in sale products. I will use the shortcode, but it would have been better if it was possible in the normal product feed with a filter on sale

    kowsaliya

    (@kowsaliya)

    Hi @paulfwp

    We understand your concern.
    You can give it a try by doing a simple rule.

    Create a rule with 0% discount for onsale products. https://nimb.ws/7AcedQ

    And use our on-sale shortcode https://nimb.ws/kxQHly.

    Hope this small hack helps you ??

    Thanks
    Team Flycart

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Get product IDS that are in sale for woocommerce product query’ is closed to new replies.