|
|
|
import shopify |
|
import os |
|
|
|
SHOP_URL = "https://863c42fc4fc6eb9dd18c84dacb21374e:[email protected]/admin" |
|
API_VERSION = "2023-10" |
|
|
|
|
|
shopify.ShopifyResource.set_site(f"{SHOP_URL}/api/{API_VERSION}") |
|
|
|
def create_product(title: str, body_html: str, price: str, image_url: str): |
|
new_product = shopify.Product() |
|
new_product.title = title |
|
new_product.body_html = body_html |
|
new_product.variants = [shopify.Variant({'price': price})] |
|
new_product.images = [shopify.Image({'src': image_url})] |
|
success = new_product.save() |
|
if not success: |
|
raise Exception(new_product.errors.full_messages()) |
|
return new_product.to_dict() |
|
|
|
if __name__ == "__main__": |
|
|
|
prod = create_product( |
|
title="AI Fitness Mirror Decal", |
|
body_html="<strong>AI‑powered form correction in your own mirror.</strong>", |
|
price="49.99", |
|
image_url="https://example.com/decal.jpg" |
|
) |
|
print("Created product:", prod["id"]) |
|
|