• I’d like to display the sale price of a product before the regular (discounted) price. I know this has something to do with get_price_html. By default, this outputs something like:

    <del>regular price</del>
    <ins>sale price</ins>

    I want to change the output so it looks like this (basically, the two prices are shown in a different order):

    <ins>sale price</ins>
    <del>regular price</del>

    How can I do this?

    Thank you!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Yes, you could use this filter:

    
    add_filter( 'woocommerce_get_price_html', 'custom_price_html', 40, 2 );
    function custom_price_html( $price, $_product ) {
    

    It will get to be a long function to take into account whether the product is single or variable, with or without tax, or free. You’ll need to rewrite the following as your custom function:
    https://docs.woocommerce.com/wc-apidocs/source-class-WC_Product_Grouped.html#164
    Your code goes in functions.php for your child theme.

    Thread Starter lucreziavannecker

    (@lucreziavannecker)

    Thanks for your reply!

    The products will all be variable products, and all on sale. I could use a bit of guidance as to what should be changed and where since I’m quite a newbie to php.

    Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Display Sale Price Before Regular Price’ is closed to new replies.