Support » Plugin: WooCommerce » WooCommerce display Price From while using Dynamic Pricing

  • Resolved anotherbreed

    (@anotherbreed)


    I’m using the WooCommerce extension Dynamic Pricing to put all the products of my store on sale. My only problem is that I am also using the following snippet of code in my functions.php:

    
    function iconic_variable_price_format( $price, $product ) {
    
        $prefix = sprintf('%s ', __('From', 'iconic'));
    
        $min_price_regular = $product->get_variation_regular_price( 'min', true );
        $min_price_sale    = $product->get_variation_sale_price( 'min', true );
        $max_price = $product->get_variation_price( 'max', true );
        $min_price = $product->get_variation_price( 'min', true );
    
        $price = ( $min_price_sale == $min_price_regular ) ?
            wc_price( $min_price_regular ) :
            '<del>' . wc_price( $min_price_regular ) . '</del>' . '<ins>' . wc_price( $min_price_sale ) . '</ins>';
    
        return ( $min_price == $max_price ) ?
            $price :
            sprintf('%s%s', $prefix, $price);
    
    }
    
    add_filter( 'woocommerce_variable_sale_price_html', 'iconic_variable_price_format', 10, 2 );
    add_filter( 'woocommerce_variable_price_html', 'iconic_variable_price_format', 10, 2 );
    

    This changes the way WooCommerce displays prices of variable products.

    Default: €5.00 – €10.00
    With the snippet: From €5.00

    When I manually set a Product on sale, the result is the following:

    From €5.00 €3.00

    Which is perfect, but when the sale price is applied using the extension Dynamic Pricing I still see the normal price From €5.00, and have to add the item to Cart to finally see that the price is discounted €5.00 €3.00.

    Any ideas about how to change the snippet above to get the discounted price appearing in the correct way (From €5.00 €3.00)?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support Thomas Shellberg

    (@shellbeezy)

    Automattic Happiness Engineer

    I would install the Debug Bar plugin along with the Action and Filter Hooks Add-On which allows you to comb through the filters applied when viewing the single product page. At first I thought that Dynamic Pricing was just using a higher priority number but I think Dynamic Pricing is not using those filters at all and thus overrides the price in another way, perhaps through woocommerce_variation_prices_price.

    When looking at the Filter Hooks output you can search for WC_Dynamic_Pricing to see how it interacts with filters.

    Plugin Support Kenin

    (@kbassart)

    Automattic Happiness Engineer

    We haven’t heard back from you in a while, so I’m going to mark this as resolved – if you have any further questions, you can start a new thread.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘WooCommerce display Price From while using Dynamic Pricing’ is closed to new replies.