Created
December 20, 2017 05:52
-
-
Save kamalinfo/d8f5e2c1aa4093fa63b85174c5f6bb89 to your computer and use it in GitHub Desktop.
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 | |
global $product; | |
$discount = ''; | |
$regurlar_price = get_post_meta( get_the_ID(), '_regular_price', true); | |
$sale_price = get_post_meta( get_the_ID(), '_sale_price', true); | |
if($regurlar_price && $sale_price ){ | |
$price = $sale_price * 100 / $regurlar_price; | |
$discount = round(100 - $price); | |
} | |
if($discount){ | |
echo '<span class="brand-color2">-'.$discount.'%</span>'; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment