Jump to content

Cart->Order issue


antonioperic

Recommended Posts

Hi,

I am working on one custom payment module and module is implementing 3rd party api. So I redirect user to payment gateway page, then when he is return I process his order.

There is situation when user cancel his order, or got some erorr and then complete order with other payment method. In this situation I will love to mark this payment as error or failed but when I do validateOrder() then my cart is removed. How can I keep cart when order is created and failed?

Thank you

Link to comment
Share on other sites

Don't create an order, don't call validateOrder if the payment gateway returned a failure.  Instead return the customer to the checkout process and display a message that the payment was cancelled or failed.  They can pick another payment method, or try again.

Link to comment
Share on other sites

As I get from code it is impossible in that way, only way is to clone Cart and assign new cart to user if Order is failed, then new cart will create new order.

 

$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;

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...