Last active
March 5, 2019 19:59
-
-
Save themepaint/b6b3ade013ee36b78dfb to your computer and use it in GitHub Desktop.
WooCommerce
This file contains 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 | |
/*Product DIscount Calculation*/ | |
//put it on Function | |
function discount_product(){ | |
global $product; | |
$discount = $product->sale_price ; | |
if ($discount) { | |
$percentage = round( ( ( $product->regular_price - $product->sale_price ) / $product->regular_price ) * 100 ); | |
$wc_percent = $price .' <span class="product-discount">'. sprintf( __('%s', 'cruise' ), $percentage . '% OFF</span>' ); | |
} | |
else{ | |
$wc_percent = $price .' <span class="no_discount">'. sprintf( __('0%s', 'cruise' ), $percentage . '% OFF</span>' ); | |
} | |
return $wc_percent; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment