Update shopify_orders.py
Browse files- shopify_orders.py +7 -26
shopify_orders.py
CHANGED
@@ -1,30 +1,11 @@
|
|
1 |
-
#
|
2 |
import shopify
|
3 |
-
import os
|
4 |
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
# Configure
|
9 |
-
shopify.ShopifyResource.set_site(f"{SHOP_URL}/api/{API_VERSION}")
|
10 |
-
|
11 |
-
def create_product(title: str, body_html: str, price: str, image_url: str):
|
12 |
-
new_product = shopify.Product()
|
13 |
-
new_product.title = title
|
14 |
-
new_product.body_html = body_html
|
15 |
-
new_product.variants = [shopify.Variant({'price': price})]
|
16 |
-
new_product.images = [shopify.Image({'src': image_url})]
|
17 |
-
success = new_product.save()
|
18 |
-
if not success:
|
19 |
-
raise Exception(new_product.errors.full_messages())
|
20 |
-
return new_product.to_dict()
|
21 |
|
22 |
if __name__ == "__main__":
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
body_html="<strong>AI‑powered form correction in your own mirror.</strong>",
|
27 |
-
price="49.99",
|
28 |
-
image_url="https://example.com/decal.jpg"
|
29 |
-
)
|
30 |
-
print("Created product:", prod["id"])
|
|
|
1 |
+
# shopify_orders.py
|
2 |
import shopify
|
|
|
3 |
|
4 |
+
def fetch_recent_orders(limit=5):
|
5 |
+
orders = shopify.Order.find(limit=limit, status="any")
|
6 |
+
return [o.to_dict() for o in orders]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
|
8 |
if __name__ == "__main__":
|
9 |
+
recent = fetch_recent_orders()
|
10 |
+
for o in recent:
|
11 |
+
print(o["id"], o["email"], o["total_price"])
|
|
|
|
|
|
|
|
|
|