0

I've added the following code to the checkout page (item.phtml).

$_regularPrice = $_product->getPrice(); 
$_finalPrice = $_product->getFinalPrice();
if($_finalPrice < $_regularPrice):
    $special_percent = ceil(100 - (( 100/$_regularPrice ) * $_finalPrice )); echo $special_percent.'%'; else: echo '0%'; 
endif;

This code is showing proper percentage if I add special price to the product. But it is not working if I add Shopping Cart Pricing Rule. The output is always 0% if I add a Shopping Cart Pricing Rule, is there a way to do the same for Shopping Cart Pricing Rule?

Thanks.

8
  • Try to re-apply the price rules Commented Oct 13, 2014 at 7:51
  • Check the values for $_regularPrice and $_finalPrice
    – Marius
    Commented Oct 13, 2014 at 7:53
  • @Marius Both are giving the same amount.
    – Nikhil
    Commented Oct 13, 2014 at 7:57
  • @user3154108 It doesn't worked
    – Nikhil
    Commented Oct 13, 2014 at 7:58
  • This means that the problem is somewhere else. Maybe the catalog or shopping cart rules expired.
    – Marius
    Commented Oct 13, 2014 at 8:05

1 Answer 1

1

Final price does not respect discount. Because final price is the PRODUCT attribute, and discount is the CART ITEM attribute. Just use the $item, not $product.

discount: $item->getDiscountAmount()

original price: $item->getCalculationPrice();

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.