Skip to content

Instantly share code, notes, and snippets.

@kloon
Created December 11, 2013 09:07
Show Gist options
  • Save kloon/7907222 to your computer and use it in GitHub Desktop.
Save kloon/7907222 to your computer and use it in GitHub Desktop.
WooCommerce Was, Now, Save % price
<?php
// Add Now: R12, Was: R15, Save 20% price for items on sale
add_action( 'woocommerce_sale_price_html', 'wc_custom_sale_price', 10, 2 );
function wc_custom_sale_price( $price, $product ) {
$percentage = round( ( ( $product->regular_price - $product->get_price() ) / $product->regular_price ) * 100 );
return sprintf( __( 'Now: %s, Was: %s, Save %s', 'woocommerce' ), woocommerce_price( $product->get_price() ), woocommerce_price( $product->regular_price ), $percentage . '%' );
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment