Prestashop, how to transfer cart to order manually

Prestashop has a nice feature that allows administrator to view a customer's shopping cart : while the shopping cart is relatively easy to use for novices, the number of steps involved in completing the transaction can discourage some users, who might be tempted to ask you for help. What can you do apart from helpinog the guy to fill in forms ? The technique below illustrates how to simulate a payment using the Cheque payment type, via the creation of a hard coded validation page. Be careul, this is for good PHP coders only as you have to interfere with low level classes from Prestashop.

  1. go to Modules / cheque / validation.php and duplicate the file to validationManual.php
  2. Paste the  code blow under the includes  to instanciante the shopping cart using the ID of the shopping cart you want to transfer to an order, here we have the id 9304
  3. change the currency id to reflect the currency you want to use, you'll find the currency id in the currency module of the prestashop administration interface
  4. call the module/cheque/validationManual.php from the browser, s if it was called after a valid paymen
  5. Go to Prestashop administration interface to check that the order has been created
  6. you might be wise to try to place a new order for testing that the manual process has not disturbed prestashop's database integrity
    // 1 . get currency ID
    $currency = new Currency(1);
    // 2 get cart id
    $cart = new Cart( 9304);
    $total = floatval(number_format($cart->getOrderTotal(true, 3), 2, '.', ''));
    $mailVars =    array(
    '{cheque_name}' => Configuration::get('CHEQUE_NAME'),
    '{cheque_address}' => Configuration::get('CHEQUE_ADDRESS'),
    '{cheque_address_html}' => nl2br(Configuration::get('CHEQUE_ADDRESS')));
    $cm = new Cheque();
    $cm->validateOrder($cart->id, _PS_OS_CHEQUE_, $total, $cm->displayName, NULL, $mailVars, $currency->id);
    $order = new Order($cm->currentOrder);
4 replies
  1. Anim
    Anim says:

    Can you help me to make order via web service in the latest prestashop version?
    I already make, customer until cart, and I am fail in place order, says: Bad Parameter given,

    Thank you

    Jagad Shalawat, Jagad Sholawat

  2. Nelson Gomez
    Nelson Gomez says:

    Hello, can you please tell me which php file in prestashop, uses so that when the user buys an item, it decrements the selected item?


Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *