Menu Close
    Hire us Request quote Reading list Switch to dark mode

    Preventing a product from being added to cart in magento

    This article is aimed towards preventing a product from being added to cart. For this we will have to call an observer.
    So we can either use observer ‘checkout_cart_product_add_after‘ or ‘controller_action_predispatch_sales_order_reorder‘.



    Now after adding an observer we need to write the action which we are going to perform, i.e, preventing a product from being added to cart. We can achieve this by using either of the following 2 ways:

    In place of $condition we need to put the condition due to which the product will not be added to cart.
    And that’s it.
    Happy coding.

    . . .


    Add Your Comment

    Be the first to comment.

    Back to Top
    Hire Us!
    Brief us about your requirements and we'll get back to you.
    Woo! Hooy!
    We have just received your message and our expert will get back to you shortly.
    Send Again