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

Feb 7, 20131552Alex 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:

Partner With Us Looking for a partner that will help you to grow your business? We are the right company to develop your webstore. Feel free to get in touch with us. We will be happy to discuss your business opportunities and provide you with a Free Quote. Talk to Andrey


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


  2. 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’)

  3. Hi Alex

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

    Thanks in advance

  4. Stefano,

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

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


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

  7. Hi Alex,


    The function changes the order status but no order history.

    Do you know how to also change the order history?

  8. Davis,

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

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

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

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


  12. Cesari,

    The class OrderHistory has a specific method for that:

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

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

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

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

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


  18. Hi, Ciro

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

Post a new comment

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