1

Magento 1.7.0.2. I need to check for a coupon code that the customer enters and then if the subtotal is over a given amount I need to change that rule so that I can cap the discount using another rule.

So far I can grab the current coupon as $coupon by using a simple if statement:

if (strtolower($coupon) == 'mycoupon') {

But then it doesn't seem to matter what combination of code I use I can't get it to update the coupon to something else. Here's one method I tried:

$coupon = 'MYNEWCOUPON';
$getCoupon = Mage::getModel('salesrule/coupon')->load($coupon, 'code');
$rule = Mage::getModel('salesrule/rule')->load($getCoupon->getRuleId());

Any ideas what else I could do here?

1

You're editing the local value of the coupon. If you want the changes to reflect in the checkout process, you will need to not just get the new rule model, but set the new rule and new coupon.

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.