• Resolved royalhound

    (@royalhound)


    This, I am hoping, is a simple code change.

    I have variable pricing for some products, which was displaying as a price range that was something like this: “AUD$xxx to AUD$XXX”. I implemented the following code to remove the two prices and only display the lower price.

    ———–

    //hide price range code
    
    function wc_varb_price_range( $wcv_price, $product ) {
     
        $prefix = sprintf('%s: ', __('From', 'wcvp_range'));
     
        $wcv_reg_min_price = $product->get_variation_regular_price( 'min', true );
        $wcv_min_sale_price    = $product->get_variation_sale_price( 'min', true );
        $wcv_max_price = $product->get_variation_price( 'max', true );
        $wcv_min_price = $product->get_variation_price( 'min', true );
     
        $wcv_price = ( $wcv_min_sale_price == $wcv_reg_min_price ) ?
            wc_price( $wcv_reg_min_price ) :
            '<del>' . wc_price( $wcv_reg_min_price ) . '</del>' . '<ins>' . wc_price( $wcv_min_sale_price ) . '</ins>';
     
        return ( $wcv_min_price == $wcv_max_price ) ?
            $wcv_price :
            sprintf('%s%s', $prefix, $wcv_price);
    }
     
    add_filter( 'woocommerce_variable_sale_price_html', 'wc_varb_price_range', 10, 2 );
    add_filter( 'woocommerce_variable_price_html', 'wc_varb_price_range', 10, 2 );

    —————–

    On the category page and the individual product page the price of the item is now displaying “AUD From: $XXXX”. I would like to remove the word “From”. This also appears on the category page of the shop. This also needs to be removed. So the price should show as the following;

    “AUD: $XXX” or
    “USD: $XXX” for US pricing etc…

    As I said I have already adjusted the funtions.php file in the theme (Sober) with the above custom code. However I cannot remove the word “From”.

    Any help would be great.

    • This topic was modified 5 years, 3 months ago by royalhound.
    • This topic was modified 5 years, 3 months ago by Jan Dembowski. Reason: Moved to Fixing WordPress, this is not an Everything else WordPress topic
    • This topic was modified 5 years, 3 months ago by bcworkz. Reason: code fixed

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator bcworkz

    (@bcworkz)

    Try changing the $prefix line to:
    $prefix = ''; //sprintf('%s: ', __('From', 'wcvp_range'));
    The existing code is made into a comment in case you want to restore it later.

    FYI, when you post code in these forums please demarcate with backticks or use the code button, otherwise the forum’s parser corrupts your code. I fixed your code snippet for you.

    Thread Starter royalhound

    (@royalhound)

    Thank you bcworkz. That worked like a dream.

    Code demarcation – apologies was not aware of the code button or the back ticks. Will do in future.

    Moderator bcworkz

    (@bcworkz)

    You’re welcome. No apology necessary, the importance of doing so is not well documented.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Removing the word “From:” in categrory and price page’ is closed to new replies.