• Resolved peteratomic

    (@peteratomic)


    Have been searching like mad for a solution to this issue. My client wants high to low price sorting (which is working) but to ALSO make the variable prices high to low.

    https://fourvisionsmarket.com/lotions-oils-more/

    So for instance, in the top block (Lotions) the prices appear in order like this:

    30.00 – 50.00
    50.00
    48.00

    This is correct in that it sorts by highest potential price on the variable product (50). However, the client wants it to actually display like this:

    50.00 – 30.00
    50.00
    48.00

    Have tried so many different search term variations and can’t find anyone trying to do the same thing.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support mcampal – a11n

    (@mcampal)

    Hi there,

    With WooCommerce out-of-the-box, the lowest price will display first on the variable product’s price range.

    Changing the order in which the price range is displayed would require customization, which is outside the scope of the support I can provide, but I’ll be happy to point you in the right direction.

    You could add the following snippet to your theme’s functions.php file as explained here:https://docs.woocommerce.com/document/using-theme-functions-php/

    /**
     * Invert price range.
     *
     * @param string $price
     * @param float  $from
     * @param float  $to
     *
     * @return string
     */
    function invert_format_price_range( $price, $from, $to ) {
        return sprintf( '%s - %s', wc_price( $to) , wc_price( $from ) );
    }
     
    add_filter( 'woocommerce_format_price_range', 'invert_format_price_range', 10, 3 );

    I hope this helps!

    Best,

    Thread Starter peteratomic

    (@peteratomic)

    FANTASTIC! That worked like a charm!

    Thank you so much @mcampal !

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘sorting high to low including variable products’ is closed to new replies.