1

I am struggling to work out how to first detect if a rule applies to a product in magento then display the amount.

I found this but you need to specify a specific rule id which isnt idea - and it doesnt detect if it applies to the current product.

//$rule = Mage::getModel('salesrule/rule')->load(5); 
//$rule->setWebsiteIds("5");    
//echo $rule->getDiscountAmount();

Thanks

  • Can you give more detail of what you want to do? Detect any rule or particular one rule? And where exactly you adding your code above? Salesrule idea is to set up conditions before applying the rule action. If you want to check if one product can apply to a product, you have to get the product to match the rule conditions. But frankly, some problem here since conditions can be nested and complicated, have to set the condition carefully to suit your purpose – RaymondM Jan 07 '16 at 03:19
  • Ideally I would like to detect any rule applied to that product and show the true price and then the original next to it. – user2353244 Jan 08 '16 at 00:15
  • You can use category price rule to achieve same goal. But if you insist doing this programmically and develop upon salesrule, it will be very compilated, salesrule is designed for cart items. – RaymondM Jan 08 '16 at 02:35
  • hmm maybe I am confused or I confused you. I think the problem is that rules dont show until the customer checks out - ideally we want to show the real price on the product page or even the category page too. Specials work this way but rules dont - as from what I understand its not calculated until the check out page. – user2353244 Jan 08 '16 at 04:16
  • if you want to retrieve the discounted price **before** a product is added to cart. You should look deep in categoryrule module. If you want to retrieve the discounted price **after** it is added to cart, please look inside salesrule module. If you still dont understand, maybe you are not ready for this. – RaymondM Jan 08 '16 at 04:23
  • Okay thanks, seams odd that we cant show the discounted price tho. I'll look into the rule module then. – user2353244 Jan 08 '16 at 04:57

0 Answers0