1

我对这个问题感到震惊,是否有任何方法可以在订单详细信息和订单 ID 的帮助下恢复购物车。我想做与 Prestashop 中的重新排序功能相同的操作。在 Magento 中有一个简单的代码来恢复购物车在最后一个订单 ID 的帮助下,如下所示:

 if ($lastQuoteId = Mage::getSingleton('checkout/session')->getLastQuoteId()) {
            $quote = Mage::getModel('sales/quote')->load($lastQuoteId);
            $quote->setIsActive(true)->save();
        }

如果这样的东西在 Prestashop 上工作。这对我会有很大的帮助。请给我您宝贵的建议。提前致谢。

4

1 回答 1

1

我在 TheDrot 的帮助下找到了这个。感谢您的参考。

$order = new Order(Order::getOrderByCartId($id_cart));
if ($order) {
        $oldCart = new Cart($id_cart);
        $duplication = $oldCart->duplicate();
        if (!$duplication || !Validate::isLoadedObject($duplication['cart'])) {
            $this->errors[] = Tools::displayError('Sorry. We cannot renew your order.');
        } elseif (!$duplication['success']) {
            $this->errors[] = Tools::displayError('Some items are no longer available, and we are unable to renew your order.');
        } else {
            $this->context->cookie->id_cart = $duplication['cart']->id;
            $context = $this->context;
            $context->cart = $duplication['cart'];
            CartRule::autoAddToCart($context);
            $this->context->cookie->write();
            if (Configuration::get('PS_ORDER_PROCESS_TYPE') == 1) {
                Tools::redirect('index.php?controller=order-opc');
            }
            Tools::redirect('index.php?controller=order');
        }
    }
于 2017-03-14T06:42:44.923 回答