Display the Sale price before Regular price in WooCommerce Display the Sale price before Regular price in WooCommerce wordpress wordpress

Display the Sale price before Regular price in WooCommerce


The following hooked function code will display the Sale price before Regular price:

add_filter( 'woocommerce_format_sale_price', 'invert_formatted_sale_price', 10, 3 );function invert_formatted_sale_price( $price, $regular_price, $sale_price ) {    return '<ins>' . ( is_numeric( $sale_price ) ? wc_price( $sale_price ) : $sale_price ) . '</ins> <del>' . ( is_numeric( $regular_price ) ? wc_price( $regular_price ) : $regular_price ) . '</del>';}

Code goes in function.php file of the active child theme (or active theme). Tested and works.


You can solve this using only jQuery and swap to element that show the regular price and sale price:

$("#element1").before($("#element2"));

or

$("#element1").after($("#element2"));

:)

and one more on js fiddle https://jsfiddle.net/nak73406/v9k7b5c1/5/