2

I am programmatically adding a product to cart if a certain coupon code is applied to cart.

I would like to check this on every page so that the product only shows up when the coupon is applied and no issues with cookies, etc.

What event can I observe for this?

2 Answers 2

2

you can use controller_action_predispatch.
This event is dispatched for every page, before the action is executed.

2
  • or use the CatalogController if you're not comfortable with Observers :) Oct 1, 2015 at 8:14
  • Thanks! I used controller_action_predispatch and works perfectly
    – blisstdev
    Oct 1, 2015 at 9:09
4

In order to add an observer to an event on every page add this in config.xml of your module.

<events>
    <controller_action_predispatch>
        <observers>
            <Namespace_ModuleName>
                <class>Namespace_ModuleName/observer</class>
                <method>Observer_action_name</method>
            </Namespace_ModuleName>
        </observers>
    </controller_action_predispatch>
</events>

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.