如何防止在magento中多次添加同一产品到购物车 [英] How to prevent adding same product to cart more then one time in magento

查看:85
本文介绍了如何防止在magento中多次添加同一产品到购物车的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是magento开发的新手.我不希望用户在购物车中再添加任何产品.如果他/她需要更改产品的数量,则需要从mycart页面中进行更改,但是添加到购物车"按钮仅允许添加一次产品,之后,当他/她单击添加到购物车"按钮时,必须说如果您要更改数量,它已经添加到购物车,请转到mycart".

I am new in magento development. I dont want user to add any product more then once to the cart.if he/she need to change the qty of the product then he/she need to change it from mycart page but add to cart button only allow once to add product, after that when he/she clicks on add to cart button it must say "it is already added to the cart if you want to change the quantity then please go to mycart".

例如,您可以访问www.flipkart.com.

for example you can see www.flipkart.com.

推荐答案

看看:

产品->库存->购物车中允许的最大数量

Product -> Inventory -> Maximum Qty Allowed in Shopping Cart

系统->配置->库存->购物车中允许的最大数量

System -> Configuration -> Inventory -> Maximum Qty Allowed in Shopping Cart

请查看使用事件/观察器自定义Magento .

您可以使用的事件例如:checkout_cart_update_items_beforecheckout_cart_product_add_after

Events you could use, are for example: checkout_cart_update_items_before and checkout_cart_product_add_after

我也建议您查看:/app/code/core/Mage/Checkout/Model/Cart.php可能有帮助的其他事件.

Also I'd suggest looking atthe: /app/code/core/Mage/Checkout/Model/Cart.php for other events that might be helpful.

在此文件中,您还将找到类似以下的代码:

In this file also, you'll find code like:

$this->getCheckoutSession()->addError(
  Mage::helper('checkout')->__('Some of the requested products are unavailable.')
);

您可以用来向客户显示错误消息.

Which you could use for displaying the the error message to the customer.

这篇关于如何防止在magento中多次添加同一产品到购物车的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆