How to change order state with some sort of API in prestashop ?

 Hello Vekia, just a short message about your modules: we confirm orders as sent by changing order status number via odbc connection from our internal database, this does not fire hooks and Amazon orders, in example, are not fired as sent. First question: does you automatic order status has a cron that auto changes from "sent" to "sent and confirmed"? Second question: how can we fire all the hooks if we change status via database? we use MS access front end, mariadb backed for tables, is there a call to via maybe http get API of some sort? Thank you in advance,
Hello,

First question: does you automatic order status has a cron that auto changes from "sent" to "sent and confirmed"?

The module you're asking for does not have cron feature.
module's workflow is fired with hook actionOrderHistoryAddAfter so it will not help you :(
 
but i've got a module that will probably work as you wish, the module is here: https://mypresta.eu/modules/ordering-process/unpaid-order-reminder.html
module has feature to change states of orders with cron jobs :)
 
The main idea of the module is to remind customers about their "pending" orders (orders that are not paid - with selected order state for example "awaiting for bankwire payment"). Option to send email with reminder can be disabled: https://i.imgur.com/iagUgjc.png (so customers will not receive emails from the module).  The other feature is to set new order state: https://i.imgur.com/YeHlNsM.png 
 
so, with plugin you can:

  • point order states that you want to change
  • point order state that will be set after "cron task" usage
  • run cron job with expected frequency (for example several times a day)

 
 
example of configuration: 



each order state change that module does run the all hooks associated with order state change process (like it is when you change state for order manually). It does it individually for each order.
it will definitely work as you wish :)
 


Second question: how can we fire all the hooks if we change status via database?

prestashop does not have feature to run hooks with api change. Some time ago i wrote tutorial about it: https://mypresta.eu/developer/execute-hooks-with-webservice.html and with some changes it can be used.

personally - if i were you - i will create a module that will have possibility to run all order state change task with special url. If you will run url of the module with http GET to change state of order (by id_order url variable) to specific order state (that will be pointed in id_order_state url variable). It will be much easier to control the task than with API since its architecture is very limited and requires changes (that can be problematic and cause issues after prestashop update). 

Share on Google Plus

About VEKIA

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.
    Blogger Comment

0 comments:

Post a Comment