2

Which observer could I use to get the coupon code inserted by the customer when this is not valid on checkout cart page?

I tried using the salesrule_validator_process but coupon code is null when it's not valid. I'm using the following code to get it:

 $quote = Mage::getSingleton('checkout/session')->getQuote();
 $coupon_code = $quote->getData('coupon_code');

1 Answer 1

1

You need to used this event :

<config>
    <global>
        <events>
            <controller_action_postdispatch_checkout_cart_couponPost>
                <observers>
                    <coupencodevalidationobserver>
                        <type>singleton</type>
                        <class>Vendor_Extension_Model_Checkout_Observer</class>
                        <method>validatecouponcode</method>
                    </coupencodevalidationobserver>
                </observers>
            </controller_action_postdispatch_checkout_cart_couponPost>
        </events>
    </global>
</config>

And in observer file you get coupen code like this :

public function validatecouponcode(Varien_Event_Observer $observer)
{

    $controller = $observer->getControllerAction();
    $coupencode = $controller->getRequest()->getParam('coupon_code');
    // Do your logic here
    return $this;
}

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.