Jump to content

Convert Cart into Order


jtchandler

Recommended Posts

I am writing a custom payment module.  Everything seems to be working except I can't figure out how to convert an user's cart into an order.  

 

I collect the information, send it off to the payment processor, and then return the info to a custom module page.  On this page I want it to covert the cart to an order and mark it paid, but I can't figure out the code to do it.  Is there a hook I should be using for this?  Is there a function for the order class?  

 

Edit: This is for Prestashop 1.5

Edited by jtchandler (see edit history)
Link to comment
Share on other sites

Finally found it.  It is the validateOrder function.  The following is working well for me in a moduleFrontController:

 

//Get cart id from $_POST

$cart_id = Tools::getvalue('cart_id');

$cart = new Cart((int)$cart_id);

$order_status = (int)Configuration::get('PS_OS_PAYMENT');

$order_total = $cart->getOrderTotal(true, Cart::BOTH);

$this->module->validateOrder($cart->id, $order_status, $order_total, "Payment Name Here", null, array(), null, false, $cart->secure_key);

 

Hope this helps someone else.

  • Like 2
Link to comment
Share on other sites

  • 7 years later...
On 1/30/2014 at 1:36 PM, jtchandler said:

Finally found it.  It is the validateOrder function.  The following is working well for me in a moduleFrontController:

 

//Get cart id from $_POST

$cart_id = Tools::getvalue('cart_id');

$cart = new Cart((int)$cart_id);

$order_status = (int)Configuration::get('PS_OS_PAYMENT');

$order_total = $cart->getOrderTotal(true, Cart::BOTH);

$this->module->validateOrder($cart->id, $order_status, $order_total, "Payment Name Here", null, array(), null, false, $cart->secure_key);

 

Hope this helps someone else.

hello,

 

could you please specify which file is this? where should i loook to edit?

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