The best way to send the order data along with the order id right after the order placement

Help for integrating the Laravel package
Forum rules
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
akropivko
Posts: 36
Joined: 20 Jan 2021, 12:49

The best way to send the order data along with the order id right after the order placement

Post by akropivko » 15 Jun 2021, 10:59

Hi!
Could you please give me a tip what is the best way to send an order data (to third party ERP system) along with the order id right after the order placement?
I guess I can't do this via a new basket plugin since there is no order id on this step yet (autoincrement).
Also it seems there is no hook like setOrder.after.
And also doing this with a new cronjob seems to be a little bit overkill.

Thanks!

Laravel 6.20.27
aimeos/aimeos-core 2020.10.24
PHP 7.4

User avatar
aimeos
Administrator
Posts: 7866
Joined: 01 Jan 1970, 00:00

Re: The best way to send the order data along with the order id right after the order placement

Post by aimeos » 16 Jun 2021, 09:04

Doing this immediately after the order is placed (resp. when the payment gateway reports that the payment is OK) is usually a bad idea but this can happen more than once. The solution in Aimeos is to create a delivery service provider (or service decorator) which sends the order data to the ERP system in it's processBatch() (preferred) or process() methods:
- https://aimeos.org/docs/latest/provider ... /delivery/
- https://aimeos.org/docs/latest/provider ... ecorators/

These methods are automatically called if the order/service/delivery job is called by a cronjob:
https://aimeos.org/docs/latest/laravel/ ... ery-minute
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

akropivko
Posts: 36
Joined: 20 Jan 2021, 12:49

Re: The best way to send the order data along with the order id right after the order placement

Post by akropivko » 16 Jun 2021, 10:08

Thanks for the reply!
...so if I have several delivery options my steps to implement this are:
1. to create a new decorator with the processBatch method implemented.
2. to add this decorator to every delivery option in my admin backend

Questions:
1. Having this, the processBatch method will be executed automatically (by the cron job) every time, when delivery status of some order has changed, correct? I just can't understand what orders will be processed every time when job runs: all the last orders or I have to point out somehow what order to process?
2. So this is for delivery statuses only, all payment statuses changes will be ignored, correct?

User avatar
aimeos
Administrator
Posts: 7866
Joined: 01 Jan 1970, 00:00

Re: The best way to send the order data along with the order id right after the order placement

Post by aimeos » 18 Jun 2021, 05:49

akropivko wrote: 16 Jun 2021, 10:08 Thanks for the reply!
...so if I have several delivery options my steps to implement this are:
1. to create a new decorator with the processBatch method implemented.
2. to add this decorator to every delivery option in my admin backend
Yes
akropivko wrote: 16 Jun 2021, 10:08 1. Having this, the processBatch method will be executed automatically (by the cron job) every time, when delivery status of some order has changed, correct? I just can't understand what orders will be processed every time when job runs: all the last orders or I have to point out somehow what order to process?
These are the used conditions for selecting orders to call the processBatch() method for:
https://github.com/aimeos/ai-controller ... #L111-L115
akropivko wrote: 16 Jun 2021, 10:08 2. So this is for delivery statuses only, all payment statuses changes will be ignored, correct?
Yes
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply