Jump to content

How do I create a new Order and get back the order ID?


falconhead

Recommended Posts

Hi,

 

I'm a newbee with prestashop and sorry if my question is very basic. I'm trying to develop a custom payment gateway module.

I have succeeded in creating a module which connects to the payment gateway with the test data to be executed.

 

I'm stuck at a point where now I'm trying to populate the test data with the dynamic data generated by the cart.

 

My question is: how can I execute the cart to create a new order and get the order ID and other order details which I can populate to send the data to the payment gateway to complete the payment.

 

Thanks,

Link to comment
Share on other sites

this way. you have use validateorder() function. this function is here /classes/paymentmodule.php

$currency = new Currency(intval(isset($_POST['currency_payement']) ? $_POST['currency_payement'] : $cookie->id_currency));
$total = floatval(number_format($cart->getOrderTotal(true, 3), 2, '.', ''));
$modulename = new modulename();
$modulename->validateOrder($cart->id,  _PS_OS_PAYMENT_, $total, $modulename->displayName, NULL, $mailVars, $currency->id);		
$order = new Order($modulename->currentOrder);

Link to comment
Share on other sites

Hi,

I have a similar problem, when gateway return errors in payments, how to get the order id but the product remains in the basket ?

Function validateOrder clear cookie and empty cart, and I would not want it to happen.

 

Thanks

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...