• Resolved Gem @White Rabit

    (@anna_tianna)


    Hi,

    I’m building a woocommerce shop and I need to show the price for a new product and second-hand product on the shop page.

    I have set up the variation but it’s currently displaying as £5-£10 I want it to display as:

    Second Hand £5
    New £10

    Please help

    Best Regards

    Gem

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi

    Please test this snippet:

    
    add_filter( 'woocommerce_variable_price_html', 'ywp_woocommerce_variable_price_html', 10, 2 );
    function ywp_woocommerce_variable_price_html( $price, $instance ) {
        if( is_archive() && is_woocommerce() ) {
            $price_arr = explode( '–', $price );
            $price = '<snapn>Second Hand ' . trim( $price_arr[0] ) . '</span><span>New ' . trim( $price_arr[1] ) . '</span>';
        }
    
        return $price;
    }

    Good luck

    Rynald0s

    (@rynald0s)

    Automattic Happiness Engineer

    Howdy!

    We haven’t heard back from you in a while, so I’m going to go ahead and mark this thread as resolved. If you have any other questions please start a new thread.

    Cheers!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Show New and Second hand Prices on Shop Page’ is closed to new replies.