Alex
Alex

Reputation: 1741

Magento cart/order validation and manipulation

I'm completely new on working with Magento and I'm going to create a module in order to validate and in some cases manipulate some cart/order information.

To be specific I'm gonna restrict the customer from buying an item more than X times.

I've started working on this a bit, but I'm not so satisfied with the solution.

This is how I've done it so far: I've created a new module with a controller which subclasses Mage_Checkout_CartController and there I've implemented the addAction-method. So every time a product is added to the cart I search through the user's order history and look for previous orders containing this product. Then I prevent it from being added and trigger an error-message.

It has a lot of shortcomings. For instance, if the customer isn't logged in at the time he can add the product, you can update the cart with too many... etc.

I would be me comfortable if I could hook on events, but I don't know where to start. Haven't found so good guides about this.

I want to do this verification when listing cart, updating cart and before submitting order.

So, my questions are:

If you have any other ideas on a better solution for this, you're very welcome to comment.

I appreciate any help. Thanks.

Upvotes: 1

Views: 2001

Answers (1)

Dmytro Zavalkin
Dmytro Zavalkin

Reputation: 5277

I think this article should answer on all your questions. See events list at the bottom of this article. Do not forget delete cache after each change made to config.xml and other xml files in your module etc folder.

Upvotes: 1

Related Questions