Created
December 11, 2013 09:07
-
-
Save kloon/7907222 to your computer and use it in GitHub Desktop.
WooCommerce Was, Now, Save % price
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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