Skip to content

AvailableCoupon ​

Type: schema

Description ​

A coupon as returned by the available-coupons endpoint. Identical to Coupon EXCEPT coupon_code is a single usable code (string) or null — the cart service flattens the upstream array to the one code the customer should use (after redemption-limit filtering). Do not confuse with the webhook Coupon schema whose coupon_code is an array.

TypeScript Definition ​

typescript
AvailableCoupon: {(components["schemas"]["DiscountCouponPromotion"] | components["schemas"]["FreeGoodCouponPromotion"] | components["schemas"]["FixedPriceCouponPromotion"] | components["schemas"]["BuyXGetYCouponPromotion"] | components["schemas"]["VolumeBasedCouponPromotion"] | (components["schemas"]["FreeShippingCouponPromotion"] & {
            /** @constant */
            coupon_type: "free-shipping"
}

Component References ​

ReferenceResolves To
components["schemas"]["DiscountCouponPromotion"]DiscountCouponPromotion
components["schemas"]["FreeGoodCouponPromotion"]FreeGoodCouponPromotion
components["schemas"]["FixedPriceCouponPromotion"]FixedPriceCouponPromotion
components["schemas"]["BuyXGetYCouponPromotion"]BuyXGetYCouponPromotion
components["schemas"]["VolumeBasedCouponPromotion"]VolumeBasedCouponPromotion
components["schemas"]["FreeShippingCouponPromotion"]FreeShippingCouponPromotion

OpenAPI Schema ​

json
{
  "title": "AvailableCoupon",
  "description": "A coupon as returned by the available-coupons endpoint. Identical to `Coupon` EXCEPT `coupon_code` is a single usable code (string) or `null` — the cart service flattens the upstream array to the one code the customer should use (after redemption-limit filtering). Do not confuse with the webhook `Coupon` schema whose `coupon_code` is an array.",
  "externalDocs": {
    "url": "https://llm-docs.commercengine.io/storefront/schemas/AvailableCoupon",
    "description": "API reference for the AvailableCoupon schema"
  },
  "allOf": [
    {
      "oneOf": [
        {
          "$ref": "#/components/schemas/DiscountCouponPromotion"
        },
        {
          "$ref": "#/components/schemas/FreeGoodCouponPromotion"
        },
        {
          "$ref": "#/components/schemas/FixedPriceCouponPromotion"
        },
        {
          "$ref": "#/components/schemas/BuyXGetYCouponPromotion"
        },
        {
          "$ref": "#/components/schemas/VolumeBasedCouponPromotion"
        },
        {
          "allOf": [
            {
              "$ref": "#/components/schemas/FreeShippingCouponPromotion"
            },
            {
              "type": "object",
              "required": [
                "coupon_type"
              ],
              "properties": {
                "coupon_type": {
                  "const": "free-shipping"
                }
              }
            }
          ]
        },
        {
          "$ref": "#/components/schemas/AcceleratedRewardCouponPromotion"
        }
      ]
    },
    {
      "type": "object",
      "required": [
        "coupon_type",
        "coupon_code",
        "application_rules",
        "can_be_used_with_promotion"
      ],
      "properties": {
        "coupon_type": {
          "enum": [
            "discount",
            "free-goods",
            "fixed-price",
            "free-shipping",
            "buy-x-get-y",
            "volume-based",
            "accelerated-rewards"
          ]
        },
        "coupon_code": {
          "description": "The single usable coupon code for this customer, or `null` when no code is available (e.g. all per-code redemption limits exhausted).",
          "type": [
            "string",
            "null"
          ]
        },
        "application_rules": {
          "type": [
            "object",
            "null"
          ],
          "properties": {
            "max_applicable_items": {
              "type": "integer"
            },
            "application_priority": {
              "enum": [
                "cheapest_first",
                "most_expensive_first",
                "first_added"
              ]
            }
          },
          "required": [
            "max_applicable_items",
            "application_priority"
          ]
        },
        "can_be_used_with_promotion": {
          "type": "boolean"
        }
      }
    }
  ]
}

Auto-generated from OpenAPI spec and TypeScript definitions

Last updated: