0

I want to know, if

 controller_action_predispatch_checkout_cart_add

will only be called, when a product is added to cart from product page, or if this event will also be called, when I add a product, which is on the wishlist of the customer to the shopping cart.

I have to deal with inconsistencies regarding my shopping cart, since I want to remove other products with certain attributes, which shouldn't be able to buy them together.

On my platform, every product which can be sold is UNIQUE and they all have a quantity of one. But sometimes it happens, that the computation of the price will take a product twice into account of the calculation.

Do you have any ideas or experience with altering the quote of the current shopping cart and even with old quotes that might be loaded, when a current quote is not used anymore?

I can provide code examples, if you think, that they might help you to better understand my problem.


It may work, if I change this code

        <controller_action_predispatch_checkout_cart_add>
            <observers>
                <customoptions>
                    <type>singleton</type>
                    <class>Namespace_Module_Model_Observer</class>
                    <method>checkoutCartProductAddBefore</method>
                </customoptions>
            </observers>
        </controller_action_predispatch_checkout_cart_add>

to

        <sales_quote_product_add_after>
            <observers>
                <customoptions>
                    <type>singleton</type>
                    <class>Namespace_Module_Model_Observer</class>
                    <method>checkoutCartProductAddBefore</method>
                </customoptions>
            </observers>
        </sales_quote_product_add_after>

What do you think?

0

controller_action_predispatch_checkout_cart_add is dispatched everytime you call the url checkout/cart/add.

When you add something to the cart from the wishlist you won't call the url mentioned above. Instead wishlist/index/cart action will be called.

If you want a single event that is dispatched every time you add something to the cart you can use sales_quote_product_add_after. but this one is dispatched immediately after a product is added to the cart.

| improve this answer | |
  • what do you think about my answer above? i cannot well-format a comment for code.. therefore I used the answer function – byebb Feb 13 '17 at 13:22
  • It should work. I think – Marius Feb 13 '17 at 14:19

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.