Getting 'Cart cannot be loaded' error in Prestashop in custom Payment Module

34 views Asked by At

This is where I'm validating the order. But all the fields of cart object are null.

public function createOrder(){
        $cart = $this->context->cart;
        $total = (float)$cart->getOrderTotal(true, Cart::BOTH);
        $customer = new Customer($cart->id_customer);
        $this->module->validateOrder($cart->id, Configuration::get('PS_OS_PAYMENT'), $total, $this->module->displayName, null, array(), $this->context->currency->id, false, $customer->secure_key);
        Tools::redirect($this->context->link->getPageLink('order-confirmation', Configuration::get('PS_SSL_ENABLED'), $this->context->language->id, 'id_cart='.$cart->id.'&id_module='.$this->module->id.'&id_order='.$this->module->currentOrder.'&key='.$customer->secure_key));
    }

How to fix this? Any help is appreciated.

I am expecting it to validate the order and redirect on order confirmation page.

0

There are 0 answers