Glue API: Manage discount vouchers in guest carts

Edit on GitHub

This endpoint allows managing discount vouchers in guest carts.

Installation

For detailed information on the modules that provide the API functionality and related installation instructions, see GLUE: Promotions & Discounts feature integration.

Apply a discount voucher to a guest cart

To apply a discount voucher to a guest cart, send the request:


POST/guest-carts/{{uuid}}/vouchers


PATH PARAMETER DESCRIPTION
{{uuid}} The unique ID of the guest cart to apply the discount voucher to. To get it, Create a guest cart or Retrieve a guest cart.

Request

HEADER KEY HEADER VALUE EXAMPLE REQUIRED DESCRIPTION
X-Anonymous-Customer-Unique-Id 164b-5708-8530 The guest user’s unique ID. The value should correspond to the value used when creating the guest cart.
QUERY PARAMETER DESCRIPTION POSSIBLE VALUES
Include Adds resource relationships to the request. vouchers
Request sample: apply a discount voucher to a guest cart

POST https://glue.mysprykershop.com/guest-carts/1ce91011-8d60-59ef-9fe0-4493ef3628b2/vouchers

{
    "data": {
        "type": "vouchers",
        "attributes": {
            "code": "sprykerku2f"
        }
    }
}
Request sample: apply a discount voucher to a guest cart with discount voucher information included

POST https://glue.mysprykershop.com/guest-carts/1ce91011-8d60-59ef-9fe0-4493ef3628b2/vouchers?include=vouchers

{
    "data": {
        "type": "vouchers",
        "attributes": {
            "code": "mydiscount-qa1ma"
        }
    }
}
ATTRIBUTE TYPE REQUIRED DESCRIPTION
code String yes The unique ID of a discount voucher to apply.

Response

Response sample: apply a discount voucher to a guest cart
{
    "data": {
        "type": "guest-carts",
        "id": "c9310692-2ab0-5edc-bb41-fee6aa828d55",
        "attributes": {
            "priceMode": "GROSS_MODE",
            "currency": "EUR",
            "store": "DE",
            "totals": {
                "expenseTotal": 0,
                "discountTotal": 21831,
                "taxTotal": 19752,
                "subtotal": 145540,
                "grandTotal": 123709,
                "priceToPay": 123709
            },
            "discounts": [
                {
                    "displayName": "5% discount on all white products",
                    "amount": 7277,
                    "code": null
                }
            ],
            "thresholds": []
        },
        "links": {
            "self": "https://glue.mysprykershop.com/guest-carts/c9310692-2ab0-5edc-bb41-fee6aa828d55"
        }
    }
}
Response sample: apply a discount voucher to a guest cart with discount voucher information included
{
    "data": {
        "type": "guest-carts",
        "id": "56a0b4e4-21d8-516f-acd5-90581c996676",
        "attributes": {
            "priceMode": "GROSS_MODE",
            "currency": "EUR",
            "store": "DE",
            "name": "Shopping cart",
            "isDefault": true,
            "totals": {...},
            "discounts": [
                {
                    "displayName": "My Discount",
                    "amount": 83133,
                    "code": null
                },
                {
                    "displayName": "10% Discount for all orders above",
                    "amount": 33253,
                    "code": null
                }
            ],
            "thresholds": []
        },
        "links": {...},
        "relationships": {
            "vouchers": {
                "data": [
                    {
                        "type": "vouchers",
                        "id": "mydiscount-qa1ma"
                    }
                ]
            }
        }
    },
    "included": [
        {
            "type": "vouchers",
            "id": "mydiscount-qa1ma",
            "attributes": {
                "amount": 83133,
                "code": "mydiscount-qa1ma",
                "discountType": "voucher",
                "displayName": "My Discount",
                "isExclusive": false,
                "expirationDateTime": "2020-02-29 00:00:00.000000",
                "discountPromotionAbstractSku": null,
                "discountPromotionQuantity": null
            },
            "links": {
                "self": "http://glue.mysprykershop.com/vouchers/mydiscount-qa1ma?include=vouchers"
            }
        }
    ]
}
INCLUDED RESOURCE ATTRIBUTE TYPE DESCRIPTION
vouchers displayName String The discount name displayed on the Storefront.
vouchers amount Integer The amount of the provided discount.
vouchers code String The discount code.
vouchers discountType String The discount type.
vouchers isExclusive Boolean If true, the discount is exclusive.
vouchers expirationDateTime DateTimeUtc The date and time on which the discount expires.
vouchers discountPromotionAbstractSku String The SKU of the products to which the discount applies. If the discount can be applied to any product, the value is null.
vouchers discountPromotionQuantity Integer Specifies the amount of the product required to be able to apply the discount. If the minimum number is 0, the value is null.

Remove a discount voucher from a guest cart

To remove a discount voucher, send the request:


DELETE/guest-carts/{{uuid}}/vouchers/{{voucher_id}}


PATH PARAMETER DESCRIPTION
{{uuid}} The unique ID of the guest cart to remove the discount voucher from. To get it, Retrieve a guest cart.
{{voucher_id}} The unique ID of the voucher to remove. To get it, Retrieve a guest cart with the vouchers resource included.

Request

HEADER KEY HEADER VALUE EXAMPLE REQUIRED DESCRIPTION
X-Anonymous-Customer-Unique-Id 164b-5708-8530 The guest user’s unique ID. The value should correspond to the value used when creating the guest cart.

Request sample: remove a discount voucher from a guest cart

DELETE http://glue.mysprykershop.com/guest-carts/1ce91011-8d60-59ef-9fe0-4493ef3628b2/vouchers/mydiscount-we3ca

Response

If the voucher is deleted successfully, the endpoints returns the 204 No Data status code.

Possible errors

CODE REASON
101 Cart with the specified ID is not found.
109 X-Anonymous-Customer-Unique-Id header is empty.
3301 Voucher with the specified ID is not found.
3302 Incorrect voucher code or the voucher cannot be applied.
3303 Cart code can’t be removed.

To view generic errors that originate from the Glue Application, see Reference information: GlueApplication errors.