Menu Close

Display the Sale price before the Regular price in WooCommerce

codeamend

Learn the details about how to display the sale price before the regular price in WooCommerce.

Use below snippet code to display the sale price before the regular price. Add this code in active theme function.php.

add_filter( 'woocommerce_format_sale_price', 'invert_sale_price_format', 10, 3 );
function invert_sale_price_format( $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>';
} 

Share

Posted in PHP, WooCommerce

You can also read...