Skip to content

list-buy-it-again-items

Method: GET
Path: /orders/buy-it-again

Tags: Orders

Summary

Retrieve buy-it-again items

Description

Lists items previously purchased by the authenticated user across paid orders (excludes orders with payment_status of pending or failed). Results are deduplicated by product_id, returning the most recent purchase for each product. Use this to power a "Buy it again" carousel on storefronts.

Storefront SDK Usage

SDK Method: sdk.order.listBuyItAgainItems()

Example:

typescript
// Basic usage
const { data, error } = await sdk.order.listBuyItAgainItems();

// With pagination and marketplace seller filtering
const { data, error } = await sdk.order.listBuyItAgainItems({
  page: 1,
  limit: 20,
  seller_id: "seller_a,seller_b"
});

if (error) {
  console.error("Failed to list buy-it-again items:", error.message);
} else {
  console.log("Items found:", data.items.length);
  console.log("Pagination:", data.pagination);

  data.items.forEach(item => {
    console.log(`${item.product_name} (${item.product_id})`);
    console.log("Variant:", item.variant_name);
    console.log("Selling price:", item.selling_price);
  });
}

TypeScript Definition

typescript
"list-buy-it-again-items": {
        parameters: {
            query?: {
                /** @description page number of pagination list */
                page?: components["parameters"]["pageParam"];
                /** @description Number of results per page. */
                limit?: components["parameters"]["pageLimitParam"];
                /** @description Filter items by one or more seller IDs. Accepts a comma-separated list (e.g. `seller_a,seller_b`). Relevant for marketplace stores. */
                seller_id?: string;
            };
            header?: never;
            path?: never;
            cookie?: never;
        };
        requestBody?: never;
        responses: {
            /** @description OK */
            200: {
                headers: {
                    [name: string]: unknown;
                };
                content: {
                    "application/json": {
                        message: string;
                        success: boolean;
                        content: {
                            items: components["schemas"]["BuyOrderItemAgain"][];
                            pagination: components["schemas"]["Pagination"];
                        };
                    };
                };
            };
            401: components["responses"]["Unauthorized"];
        };
    };

Component References

ReferenceResolves To
components["parameters"]["pageParam"]pageParam
components["parameters"]["pageLimitParam"]pageLimitParam
components["schemas"]["BuyOrderItemAgain"]BuyOrderItemAgain
components["schemas"]["Pagination"]Pagination
components["responses"]["Unauthorized"]Unauthorized

Parameters

  • page (query): page number of pagination list
  • limit (query): Number of results per page.
  • seller_id (query): Filter items by one or more seller IDs. Accepts a comma-separated list (e.g. seller_a,seller_b). Relevant for marketplace stores.

Responses

200

OK

401

Not authorized for given operation on the Resource

OpenAPI Definition

json
{
  "tags": [
    "Orders"
  ],
  "operationId": "list-buy-it-again-items",
  "summary": "Retrieve buy-it-again items",
  "description": "Lists items previously purchased by the authenticated user across paid orders (excludes orders with `payment_status` of `pending` or `failed`). Results are deduplicated by `product_id`, returning the most recent purchase for each product. Use this to power a \"Buy it again\" carousel on storefronts.",
  "externalDocs": {
    "url": "https://llm-docs.commercengine.io/storefront/operations/list-buy-it-again-items",
    "description": "API reference for the list-buy-it-again-items operation"
  },
  "parameters": [
    {
      "$ref": "#/components/parameters/pageParam"
    },
    {
      "$ref": "#/components/parameters/pageLimitParam"
    },
    {
      "name": "seller_id",
      "in": "query",
      "description": "Filter items by one or more seller IDs. Accepts a comma-separated list (e.g. `seller_a,seller_b`). Relevant for marketplace stores.",
      "required": false,
      "schema": {
        "type": "string"
      }
    }
  ],
  "responses": {
    "200": {
      "description": "OK",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "required": [
              "message",
              "success",
              "content"
            ],
            "properties": {
              "message": {
                "type": "string"
              },
              "success": {
                "type": "boolean"
              },
              "content": {
                "properties": {
                  "items": {
                    "type": "array",
                    "items": {
                      "$ref": "#/components/schemas/BuyOrderItemAgain"
                    }
                  },
                  "pagination": {
                    "$ref": "#/components/schemas/Pagination"
                  }
                },
                "required": [
                  "items",
                  "pagination"
                ],
                "type": "object"
              }
            }
          }
        }
      }
    },
    "401": {
      "$ref": "#/components/responses/Unauthorized"
    }
  },
  "security": [
    {
      "Authorization": []
    }
  ],
  "x-speakeasy-group": "orders",
  "x-speakeasy-ignore": false,
  "x-speakeasy-name-override": "listBuyItAgainItems"
}

Auto-generated from OpenAPI spec and TypeScript definitions

Last updated: