Shopify Order API Call Interval
I have integrated Shopify Order API. Reference Link
Currently fetching orders based on
created_at_min field. I am calling API in every 10 min of interval like if last API called at 11:00 AM so the next API will fetch order whichever is created after 11:00AM and script will keep time of the current API call.
Timezone also set in my script code based on shopify timezone.
Issue is if order created at 11:00 AM and I am trying to fetch order which are created after 11:20 AM still 11:00 AM created orders are coming.
What should be the ideal time interval to call order API?
My code is below:
$lastScriptRun = $this->selectLastRun(); // Fetching last run time from database // Here creating current time to store in database $estDate = new DateTime( date("Y-m-d h:i:s") , new DateTimeZone('UTC')); $estDate->setTimezone(new DateTimeZone('US/Pacific')); $scriptStart = $estDate->format('c'); // Fetching orders $orders = $shopify->Order->get( array('status' => 'any', 'created_at_min' => $lastScriptRun) ); ....... // [after some code] // Updating last API call time into database $this->updateLastRun($scriptStart);
I found the solution.
This line was not returning UTC time properly.
$estDate = new DateTime( date("Y-m-d h:i:s") , new DateTimeZone('UTC'));
$estDate = new DateTime( gmdate("Y-m-d\T00:00:00\Z") );
Solution: Ideal time can be anything (standard 30 min to call an API I set for my Application).
- → "failed to open stream" error when executing "migrate:make"
- → October CMS Plugin Routes.php not registering
- → OctoberCMS Migrate Table
- → OctoberCMS Rain User plugin not working or redirecting
- → October CMS Custom Mail Layout
- → October CMS - How to correctly route
- → October CMS create a multi select Form field
- → October CMS - Conditionally Load a Different Page
- → How to disable assets combining on development in OctoberCMS
- → October CMS - Radio Button Ajax Click Twice in a Row Causes Content to disappear
- → OctoberCms component: How to display all ID(items) instead of sorting only one ID?
- → In OctoberCMS how do you find the hint path?
- → How to register middlewares in OctoberCMS plugin?