doudouji2016 2011-08-31 14:23
浏览 130

Magento购物车/订单验证和操作

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:

  • How do I add observers on these events in my module? I couldn't get config.xml-configuration for event observing to work. I also need to know the names of these events.
  • How do I manipulate the quantity of an item in cart / delete it? When updating cart with too many of the products I want to change the quantity and trigger an error.

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

I appreciate any help. Thanks.

  • 写回答

1条回答 默认 最新

  • douzhuiqing1151 2011-09-02 23:08
    关注

    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.

    评论

报告相同问题?

悬赏问题

  • ¥15 BP神经网络控制倒立摆
  • ¥20 要这个数学建模编程的代码 并且能完整允许出来结果 完整的过程和数据的结果
  • ¥15 html5+css和javascript有人可以帮吗?图片要怎么插入代码里面啊
  • ¥30 Unity接入微信SDK 无法开启摄像头
  • ¥20 有偿 写代码 要用特定的软件anaconda 里的jvpyter 用python3写
  • ¥20 cad图纸,chx-3六轴码垛机器人
  • ¥15 移动摄像头专网需要解vlan
  • ¥20 access多表提取相同字段数据并合并
  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
  • ¥20 Java-Oj-桌布的计算