Ai knowledge and logicHelpers

shopify_get_customer_orders

Retrieve a Shopify customer's orders by email address.

shopify_get_customer_orders(context: dict, email: str) -> list[dict]

Retrieves all orders for a Shopify customer by email, including fulfillment details, line items, pricing, and addresses. Returns an empty list if no orders are found.

Requires the Shopify integration to be installed for the business.


Parameters

NameTypeDescription
contextdictThe context object passed to your action
emailstrThe customer's email address

Returns

list[dict] — A list of order objects with fulfillment details, line items, pricing, addresses, etc. Returns an empty list if no orders are found.


Examples

Look up recent orders for a customer

def execute_action(context):
    email = context["args"]["email"]
    orders = shopify_get_customer_orders(context, email)

    if not orders:
        return {"found": False, "message": "No orders found for this email."}

    return {
        "found": True,
        "orderCount": len(orders),
        "orders": [
            {
                "id": o["id"],
                "name": o["name"],
                "totalPrice": o["totalPrice"],
                "fulfillmentStatus": o.get("fulfillmentStatus"),
            }
            for o in orders
        ],
    }

Check if a specific order belongs to the customer

def execute_action(context):
    email = context["args"]["email"]
    order_name = context["args"]["orderName"]
    orders = shopify_get_customer_orders(context, email)

    match = next((o for o in orders if o["name"] == order_name), None)

    if match is None:
        return {"error": f"Order {order_name} not found for this customer."}

    return {"order": match}

On this page