Is there any way to reverse the order of "Sales price" and "Regular prcie" in woocommerce?

1k views Asked by At

Usually it will be displayed as "Regular price" first with a cross line and "Sale price" second . I wish to reverse the order . Researched on google about it,nothing worked . anyone implemented ??

1

There are 1 answers

1
Domain On

Here is one of the solution which you can use

add_filter('woocommerce_sale_price_html', 'wdm_change_price_text', 10, 2);

function wdm_change_price_text( $price, $this_object ) {
    $display_price       = $this_object->get_display_price();
    $display_regular_price   = $this_object->get_display_price($this_object->get_regular_price());
    $price='<ins>' . wc_price($display_price) . '</ins>' . $this_object->get_price_suffix() . '<del>' . wc_price($display_regular_price) . '</del> ';
    return $price;
}

Addition there are other filter for different types of product so you might also need to add the function to them too.

//woocommerce_variable_sale_price_html
//woocommerce_variation_sale_price_html
//woocommerce_free_sale_price_html

Previous Price

enter image description here

After Customization Using the above code

enter image description here

Have tested the code it works for me. Try the code and let me know if this fulfills your requirements.