Prestashop 订单状态问题和购物车

Prestashop order status issue and cart

我正在开发集成第三方的支付模块api。来自 api 的一些订单失败了,我想将它们标记为付款错误 api 消息错误,但是当我创建订单并且 OrderStatus 失败时,我丢失了我的购物车。在这种情况下,我希望用户保留他的购物车并可能选择其他付款方式。

我该怎么做?

thnx

这在 Presta 中不可能以任何常规方式执行,因此如果您想让订单状态失败并为用户保留购物车,您需要克隆购物车并将其设置在上下文中

        $newCart = $cart->duplicateObject();
        $products = $cart->getProducts();

        foreach($products as $product) {
            $newCart->updateQty($product['cart_quantity'], $product['id_product']);
        }

        $newCart->save();
        Hook::exec('actionCartSave');

        $this->context->cookie->id_cart = $newCart->id;