Skip to content

Instantly share code, notes, and snippets.

@WPDevHQ
Last active March 18, 2016 00:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save WPDevHQ/58718a3316b31bded9e0 to your computer and use it in GitHub Desktop.
Save WPDevHQ/58718a3316b31bded9e0 to your computer and use it in GitHub Desktop.
Display WooCommerce discount in amount i.e. You Save £3.00
<?php
function themeslug_custom_sales_price( $price, $product ) {
$currency = get_woocommerce_currency_symbol();
$percentage = round( $product->regular_price - $product->sale_price, 2 );
return $price . sprintf( __(' <br /><span class="price_save">You Save ' . $currency . '%s', 'woocommerce' ), $percentage . '</span>' );
}
add_filter( 'woocommerce_sale_price_html', 'themeslug_custom_sales_price', 10, 2 ); ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment