0

I have a specific shopping cart rule that checks weather 3 items or greater of products from certain categories have been added to the cart, and then gives a discount on a specific Item ( I will call it "Y" in this case).

Magento will only apply the discount on Item Y if it has been added to the cart.

What I am trying to do is display the option to add the product "Y" on the cart page (cart.phtml) if the user has not yet added it to the basket.

0

Welcome to the rabbit hole. You are going to have to deal with Mage/SalesRule and most likely the generic Mage/Rule.

However, as I've mentioned before, shopping cart rule is a very bad name. They're not shopping cart rules, they are checkout, aka Cash Register rules, as they're not evaluated in the cart but in the checkout.

If you really want to do this, you will have to duplicate the rule evaluation code from the checkout and probably alter it, because some rules (like free shipping) depend on the availability of an address object or customer group, which you can't count on. Start with Mage::getModel('salesrule/rule')->getCollection().

Personally, I would hardcode this and just check for the products in question in the cart, if this is a one time deal, but if this is common functionality for the shop, I wish you the best of luck ;-)

Edit: Assuming you have at least a rule ID, you can get conditions using Mage::getModel('salesrule/rule')->load($id)->getConditions(). The implementation is in Mage_Rule_Model_Abstract.

  • Hi Melvyn, Thanks for your comment, the reason why i called them shopping cart rule, is because that is where I place the condition logic, and I wanted to specify that that I want grab the condition logic and check weather it has been "activated" in the checkout. I have managed to get the current applied rule with: $appliedRuleIds = Mage::getSingleton('checkout/session')->getQuote()->getAppliedRuleIds(); But I was wondering if there is a way to get if the ->Condition<- of that specific rule has been applied rather then the rule itself. – Meserlian Feb 19 '15 at 11:37
  • Reset cookies or clear frontend cookie. Add the products to the cart. Do not visit the checkout. Now check getAppliedRuleIds(). It will be empty, because they have not been evaluated. They get evaluated if you visit the checkout. – Melvyn Feb 19 '15 at 13:29
  • 1
    "...as they're not evaluated in the cart but in the checkout." sure about that? Shopping cart rules are done in cart and checkout. – ProxiBlue Jun 29 '17 at 23:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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