def sync_old_orders(): frappe.set_user('Administrator') shopify_settings = frappe.get_doc('Shopify Settings') if not shopify_settings.sync_missing_orders: return url = get_url(shopify_settings) session = get_request_session() try: res = session.get(url, headers=get_header(shopify_settings)) res.raise_for_status() orders = res.json()["orders"] for order in orders: if is_sync_complete(shopify_settings, order): stop_sync(shopify_settings) return sync_sales_order(order=order, old_order_sync=True) last_order_id = order.get('id') if last_order_id: shopify_settings.load_from_db() shopify_settings.last_order_id = last_order_id shopify_settings.save() frappe.db.commit() except Exception as e: raise e
def sync_item_from_shopify(shopify_settings, item): url = get_shopify_url("/admin/products/{0}.json".format(item.get("product_id")), shopify_settings) session = get_request_session() try: res = session.get(url, headers=get_header(shopify_settings)) res.raise_for_status() shopify_item = res.json()["product"] make_item(shopify_settings.warehouse, shopify_item) except Exception as e: raise e
def sync_item_from_shopify(shopify_settings, item): url = get_shopify_url("admin/api/2021-04/products/{0}.json".format(item.get("product_id")), shopify_settings) session = get_request_session() try: res = session.get(url, headers=get_header(shopify_settings)) res.raise_for_status() shopify_item = res.json()["product"] make_item(shopify_settings.warehouse, shopify_item) except Exception as e: raise e