【问题标题】:Magento cart error "Maximum one item to add the shopping cart."Magento 购物车错误“最多可添加一件商品加入购物车。”
【发布时间】:2012-06-29 20:14:27
【问题描述】:

我检查了system -> config -> Inventory 中的选项,它设置为 1000 Maximum Qty Allowed in Shopping Cart 我可以添加相同的产品,因此它会增加该产品的数量,但如果我添加另一个产品,我会得到这个 购物车中允许的最大数量,知道如何修复购物车,以便能够将更多商品添加到购物车中吗?

PS:我有 Magento 版本。 1.6.1.0

提前谢谢大家!

【问题讨论】:

  • 您能否发布您在尝试将商品添加到购物车时收到的确切错误文本?这样我们就可以找到 Magento 在哪里抛出导致您的错误的异常,然后检查围绕该错误的 PHP 逻辑以了解它拒绝您的项目的原因。
  • @AlanStorm 谢谢,错误是“最多可以添加一项购物车”。 ,您要我检查哪个文件?
  • 默认的 1.6 CE 代码中不会出现确切的错误消息/措辞。这对我来说是有人更改了您的错误消息,或者有第三方扩展程序抛出了该错误。您需要找到它出现在哪个文件中(搜索“添加购物车的商品”),这应该可以帮助您找到它。
  • 没发现问题,我检查了每个地方..你能给我更多的提示吗?

标签: magento-1.6 magento


【解决方案1】:

我想建议您执行以下操作:

  1. 首先检查系统 -> 配置 -> 所有商店的库存设置。通常,当不同商店级别的设置不合适时,用户会收到此类错误。
  2. 但如果您在添加其他产品时遇到此错误,请转到产品的“库存”选项卡并检查购物车中允许的最大数量是否正确填写。

【讨论】:

    【解决方案2】:

    您的错误“最多可将一件商品添加到购物车”。是非常独特的,它实际上是一个自定义错误,不是 Magento 原生的。我在我的一个客户的一些代码中找到了它。您必须在几个文件中查找以下代码块:

          if ($cartItems >= 1) {
                Mage::getSingleton('core/session')->addError($this->__('Maximum one item to add the shopping cart.'));
                $this->_goBack();
                return;
           }
    

        if ($params['product'] != $productId) {
            if ($cartItems >= 1) {
                $this->_getSession()->addError($this->__('Maximum one item to add the shopping cart.'));
                $this->_goBack();
                return;
           }
        }
    

        if ($params['product'] != $productId) {
            if ($cartItems > 1) {
                Mage::getSingleton('checkout/session')->addError($this->__('Maximum one product to add the shopping cart.'));
                $this->_redirect('checkout/cart');
                return;
            }
        }
    

           if ($item->getProductId() != $productId) {
               if ($cartItems >= 1) {
                    $this->_getSession()->addError($this->__('Maximum one item to add the shopping cart.'));
                    $this->_goBack();
                    return;
                }
            }
    

    你可能会在/app/code/local/{Name}/{Module}/controllers/Checkout/CartController.php/app/code/local/{Name}/{Module}/controllers/Checkout/OnepageController.php/app/code/local/{Name}/{Module}/controllers/Sales/OrderController.php找到它们 值得一提的是,{Name} 不一定限于一个扩展名......我已经找到了多个,请在 /app/code/local 中的所有文件中执行搜索以确保。 为了“修复”它,请将if ($cartItems > 1) { 中的“1”更改为其他(更高的)数字,或者将 if 语句注释掉并将其替换为 if(false) {

    【讨论】:

      【解决方案3】:
       if ($params['product'] != $productId) {
              if ($cartItems > 1) {
                  Mage::getSingleton('checkout/session')->addError($this->__('Maximum one product to add the shopping cart.'));
                  $this->_redirect('checkout/cart');
                  return;
              }
          }
      

      【讨论】:

        猜你喜欢
        • 2020-01-14
        • 2015-07-26
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-12-19
        • 1970-01-01
        相关资源
        最近更新 更多