Skip to content

evaluate-promotions

Method: GET
Path: /carts/{id}/evaluate-promotions

Tags: Carts

Summary

Evaluate promotions

Description

Evaluate applicable & inapplicable promotions based on the specified cart.

Storefront SDK Usage

SDK Method: sdk.cart.evaluatePromotions()

Example:

typescript
const { data, error } = await sdk.cart.evaluatePromotions({
  id: "01H9CART12345ABCDE"
});

if (error) {
  console.error("Failed to evaluate promotions:", error.message);
} else {
  const applicable = data.applicable_promotions || [];
  const inapplicable = data.inapplicable_promotions || [];

  console.log("Applicable promotions:", applicable.length);
  applicable.forEach(promo => {
    console.log(`- ${promo.name}: ${promo.savings_message}`);
  });

  console.log("Inapplicable promotions:", inapplicable.length);
  inapplicable.forEach(promo => {
    console.log(`- ${promo.name}: ${promo.reason}`);
  });
}

TypeScript Definition

typescript
"evaluate-promotions": {
        parameters: {
            query?: never;
            header?: never;
            path: {
                /** @description Cart Id */
                id: string;
            };
            cookie?: never;
        };
        requestBody?: never;
        responses: {
            /** @description OK */
            200: {
                headers: {
                    [name: string]: unknown;
                };
                content: {
                    "application/json": {
                        message: string;
                        success: boolean;
                        content: {
                            applicable_promotions: components["schemas"]["ApplicablePromotion"][];
                            inapplicable_promotions: components["schemas"]["InapplicablePromotion"][];
                        };
                    };
                };
            };
            401: components["responses"]["Unauthorized"];
        };
    };

Component References

ReferenceResolves To
components["schemas"]["ApplicablePromotion"]ApplicablePromotion
components["schemas"]["InapplicablePromotion"]InapplicablePromotion
components["responses"]["Unauthorized"]Unauthorized

Responses

200

OK

401

Not authorized for given operation on the Resource

OpenAPI Definition

json
{
  "tags": [
    "Carts"
  ],
  "operationId": "evaluate-promotions",
  "summary": "Evaluate promotions",
  "description": "Evaluate applicable & inapplicable promotions based on the specified cart.",
  "externalDocs": {
    "url": "https://llm-docs.commercengine.io/storefront/operations/evaluate-promotions",
    "description": "API reference for the evaluate-promotions operation"
  },
  "parameters": [],
  "responses": {
    "200": {
      "description": "OK",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "required": [
              "message",
              "success",
              "content"
            ],
            "properties": {
              "message": {
                "type": "string"
              },
              "success": {
                "type": "boolean"
              },
              "content": {
                "properties": {
                  "applicable_promotions": {
                    "type": "array",
                    "items": {
                      "$ref": "#/components/schemas/ApplicablePromotion"
                    }
                  },
                  "inapplicable_promotions": {
                    "type": "array",
                    "items": {
                      "$ref": "#/components/schemas/InapplicablePromotion"
                    }
                  }
                },
                "required": [
                  "applicable_promotions",
                  "inapplicable_promotions"
                ],
                "type": "object"
              }
            }
          }
        }
      }
    },
    "401": {
      "$ref": "#/components/responses/Unauthorized"
    }
  },
  "security": [
    {
      "Authorization": []
    }
  ],
  "x-speakeasy-group": "carts",
  "x-speakeasy-ignore": true,
  "x-speakeasy-name-override": "listPromotions"
}

Auto-generated from OpenAPI spec and TypeScript definitions

Last updated: