想要在 Prestashop 中恢复带有订单 ID 和详细信息的购物车?

Want to restore the cart with the order id and details in Prestashop?

我对这个问题感到震惊,有什么方法可以借助订单详细信息和订单 id.I 来恢复购物车 id.I 想像 Prestashop.In Magento 中的重新订购功能一样有一个简单的代码可以借助最后的订单 ID 恢复购物车,如下所示:

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

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

我在 TheDrot.Thanks 的帮助下找到了这个以供参考。

$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');
        }
    }