File size: 601 Bytes
a9a3550
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import json
import shopify

def get_product_details(handle):
    try:
        # Shopify products can be searched by handle using the API
        products = shopify.Product.find(handle=handle)
        if products:
            product = products[0]
            return json.dumps({
                "title": product.title,
                "handle": product.handle,
                "status": product.status,
                "product_type": product.product_type
            })
        return json.dumps({"error": "Product not found"})
    except Exception as e:
        return json.dumps({"error": str(e)})