Get Free Audit

How To Change An Order Status With A PHP Script In Prestashop

Feb 7, 2013

6886 Alex Simonchik

How To Change An Order Status With A PHP Script In Prestashop

Here is a nice PHP code for you to easily change the status of an order in your Presta store.


For example, you want to change the order with id 1 to the status with id 3:


Make the sales grid of your webstore more informative with Orders Grid Extended Magento extension by BelVG.

pre-order_1

Prestashop Extensions by BelVG

Take your online store to the next level

Download here
Andrey Dubina
Partner With Us Looking for a partner to grow your business? We are the right company to bring your webstore to success. Talk to Andrey

24 Comments

  1. Hi, Ciro

    You most likely have a check on the success page with the status result. Please contact our support to find out more.

  2. With your code on order confirmation page i got this message:

    “We noticed a problem with your order. If you think this is an error, you can contact us at Customer support.”

    And the new state is not added to the order.

    Thanks

  3. Hi, Ciro
    We don’t understand how our code is related to order confirmation page. By the way, if you have custom modules, they can influence any part of Prestashop.

  4. Hi,
    i tried your code but it seems to break other modules: i have installed some other payment methods such as codfee and when i execude your code, codfee confirmation order page asks for smary variables and seems to be not load correctly.

    I hope to have been clear.

  5. Hi Guys,
    I am not sure I understand the code.
    I want to change EVERY orders having status X , to status Y.

    This code would only change the order id=1 (only 1 order..).

    Can you help ? thanks!

  6. Hi. is it possible use this in a cronjob? like setting a time rule (for orders made after 5 days , for example)
    could you please give us how to do it? thanks

  7. Cesari,

    The class OrderHistory has a specific method for that:

  8. Hi,
    I try your code, it works perfectly, thanks!

    But it seems that the email for with this status is not send.
    Do you know how to send this email.

    Thanks.

  9. Joel, sure this is possible. I would recommend you to use Cron for this purpose, and you can find a sample code in the article (in the example of changing order status #1).

  10. Hi Alex,

    Do you know if it’s possible to setup an automatic status change, ie once an order id is set to shipped – it automatically changes to ‘delivered’ after something like 3-4 days? If so, how would you propose it could be done?

    Many Thanks,
    Joel

  11. Davis,

    What are you talking about exactly? Changes in the order history are also saving, because we use OrderHistory class.

  12. Hi Alex,

    Tnks!

    The function changes the order status but no order history.

    Do you know how to also change the order history?

  13. Thomas, what version do you mean as in 1.5.х changeIdOrderState() function is enough.

  14. In your order confirm script, first include the prestashop framework:

    include_once(dirname(__FILE__).’/../../config/config.inc.php’);
    include_once(dirname(__FILE__).’/../../init.php’);

  15. Stefano,

    It is meant here that you need to create a module to use the hook ‘OrderConfirmation’

  16. Hi Alex

    I can’t find the php file to modify according your tip.
    I have PS 1.5.4.0
    Are you so glad to give me the pattern to find this file?
    eg. root/…/…/file.php

    Thanks in advance

  17. Simon,

    The article describes how to change the order status with the help of the hook hookOrderConfirmation.

    Therefore, first you need to create a module which would use it. The order status is defined by the
    payment module which customer used when making the purchase. For instance, for the payment
    module bankwire the status will be saved in the constant Configuration::get(‘PS_OS_BANKWIRE’). While when paying by cheque it will be saved in Configuration::get(‘PS_OS_CHEQUE’)

  18. Hi! i need this trick! Which file i need to edit? (classes/… ? )
    I need to make ALL orders, paid by paypal, check and others.. ALWAYS in : “waiting approval” so then i will change in others status i made.

    ex. I buy and pay with paypal (or on delivery), the order MUST to be in “waiting approval”, or how i will rename it, and then i will change in “in progress” etc… Usually the new orders, are in “working”. I don’t want that!

    Thanks!

Post a new comment

BelVG Newsletter
Subscribe to our mailing list and get interesting stuff and updates to your email inbox.
Email *