Get the Discount rule/price from Woocommerce Template
-
Hello,
On my woocommerce template, we have altered the “sales-flash.php” under woocommerce/loop directory in the template, and instead of just echoing out “Sale” we calculate a discount as follows:
$sale_price = $product->get_sale_price(); $regular_price = $product->get_regular_price(); $diff = $regular_price-$sale_price; $discount = ($diff/$regular_price) * 100;
This gives us a percentage discount.
When we use the Woo Discount Rules, the “sales price” is only pulling the product discount. but the front end is reflecting the discounted price.
So for example:
Product has a price of $300, with a sales price of $200 this means our calculation will display a 33% discount instead of the words “sale” on the sales flash.
When we use Woo Discount Rule of 50% over the category, the price HTML displays sales price of $150, regular price of $300. but the discount still reflects 33% (because the $product->get_sales_price(); is still returning $200 instead of the discount rules price.
Is there ANY way I can either pull the discount rule 50%, or the price discount $150 echoed out under price HTML??
Appreciate any help I can get.
- The topic ‘Get the Discount rule/price from Woocommerce Template’ is closed to new replies.