Shopify orders does not sync

Hi @hariskadir

I have error my system can’t syns orders correct ( Shopify and ErpNext use Timezone +08:00) . So I find the root error is timezone from updated_at_min when get json /admin/orders.json

So I edit code change use timezone to utc and It run, pls check, and update code thanks.

utc_dt = timezone_abbr.astimezone (pytz.utc)
return 'updated_at_min="{0}"'.format(utc_dt.strftime("%Y-%m-%d %H:%M:%S"))

erpnext_shopify/erpnext_shopify/shopify_requests.py

Original code

def get_filtering_condition():
	shopify_settings = get_shopify_settings()
	if shopify_settings.last_sync_datetime:

		last_sync_datetime = get_datetime(shopify_settings.last_sync_datetime)
		timezone = pytz.timezone(get_time_zone())
		timezone_abbr = timezone.localize(last_sync_datetime, is_dst=False)
		return 'updated_at_min="{0} {1}"'.format(last_sync_datetime.strftime("%Y-%m-%d %H:%M:%S"), timezone_abbr.tzname())
	return ''

Fixed code

def get_filtering_condition():
	shopify_settings = get_shopify_settings()
	if shopify_settings.last_sync_datetime:

		last_sync_datetime = get_datetime(shopify_settings.last_sync_datetime)
		timezone = pytz.timezone(get_time_zone())
		timezone_abbr = timezone.localize(last_sync_datetime, is_dst=False)

		utc_dt = timezone_abbr.astimezone (pytz.utc)
		return 'updated_at_min="{0}"'.format(utc_dt.strftime("%Y-%m-%d %H:%M:%S"))

	return ''
1 Like