Glue API: Retrieve discounts in guest carts

Edit on GitHub

This document describes how to retrieve cart rules, vouchers, and promotional items in guest carts. For full information on the endpoint, see Manage guest carts of registered users.

Installation

For detailed information on the modules that provide the API’s functionality and any related installation instructions, see:

Retrieve a guest cart

To retrieve a guest cart, send the following request:


GET /guest-carts


Guest cart ID

Guest users have one guest cart by default. If you already have a guest cart, you can optionally specify its ID when adding items. To do that, use the following endpoint. The information in this section is valid for both of the endpoints.

GET /guest-carts/{{guestCartId}}

PATH PARAMETER DESCRIPTION
{{guestCartId}} The unique ID of the guest cart. To get it, retrieve a guest cart.
Note

When retrieving the cart with guestCartId, the response includes a single object, and when retrieving the resource without specifying it, you get an array containing a single object.

Request

HEADER KEY HEADER VALUE EXAMPLE REQUIRED DESCRIPTION
X-Anonymous-Customer-Unique-Id 164b-5708-8530 A Guest user’s unique ID. For security purposes, we recommend passing a hyphenated alphanumeric value, but you can pass any. If you are sending automated requests, you can configure your API client to generate this value.
PATH PARAMETER DESCRIPTION Possible values
include Adds resource relationships to the request.
  • cart-rules
  • promotional-items
  • vouchers
REQUEST USAGE
GET https://glue.mysprykershop.com/guest-carts?include=cart-rules Retrieve a guest cart with information about the cart rules.
GET https://glue.mysprykershop.com/guest-carts?include=vouchers Retrieve a guest cart with information about vouchers.

Response

Response sample: retrieve a guest cart with cart rules included
{
    "data": [
        {
            "type": "guest-carts",
            "id": "f8782b6c-848d-595e-b3f7-57374f1ff6d7",
            "attributes": {
                "priceMode": "GROSS_MODE",
                "currency": "EUR",
                "store": "DE",
                "name": "Shopping cart",
                "isDefault": true,
                "totals": {
                    "expenseTotal": 0,
                    "discountTotal": 10689,
                    "taxTotal": 15360,
                    "subtotal": 106892,
                    "grandTotal": 96203,
                    "priceToPay": 96203
                },
                "discounts": [
                    {
                        "displayName": "10% Discount for all orders above",
                        "amount": 10689,
                        "code": null
                    }
                ],
                "thresholds": []
            },
            "links": {
                "self": "https://glue.mysprykershop.com/guest-carts/f8782b6c-848d-595e-b3f7-57374f1ff6d7"
            },
            "relationships": {
                "cart-rules": {
                    "data": [
                        {
                            "type": "cart-rules",
                            "id": "1"
                        }
                    ]
                }
            }
        }
    ],
    "links": {
        "self": "https://glue.mysprykershop.com/cart-codes?include=cart-rules"
    },
    "included": [
        {
            "type": "cart-rules",
            "id": "1",
            "attributes": {
                "amount": 10689,
                "code": null,
                "discountType": "cart_rule",
                "displayName": "10% Discount for all orders above",
                "isExclusive": false,
                "expirationDateTime": "2020-12-31 00:00:00.000000",
                "discountPromotionAbstractSku": null,
                "discountPromotionQuantity": null
            },
            "links": {
                "self": "https://glue.mysprykershop.com/cart-rules/1"
            }
        }
    ]
}
Response sample: retrieve a guest cart with a cart rule and a discount voucher
{
    "data": {
        "type": "guest-carts",
        "id": "1ce91011-8d60-59ef-9fe0-4493ef3628b2",
        "attributes": {...},
        "links": {...},
        "relationships": {
            "vouchers": {
                "data": [
                    {
                        "type": "vouchers",
                        "id": "mydiscount-yu8je"
                    }
                ]
            },
            "cart-rules": {
                "data": [
                    {
                        "type": "cart-rules",
                        "id": "1"
                    }
                ]
            }
        }
    },
    "included": [
        {
            "type": "vouchers",
            "id": "mydiscount-yu8je",
            "attributes": {
                "amount": 49898,
                "code": "mydiscount-yu8je",
                "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-yu8je"
            }
        },
        {
            "type": "cart-rules",
            "id": "1",
            "attributes": {
                "amount": 19959,
                "code": null,
                "discountType": "cart_rule",
                "displayName": "10% Discount for all orders above",
                "isExclusive": false,
                "expirationDateTime": "2020-12-31 00:00:00.000000",
                "discountPromotionAbstractSku": null,
                "discountPromotionQuantity": null
            },
            "links": {
                "self": "http://glue.mysprykershop.com/cart-rules/1"
            }
        }
    ]
}

General cart information

RESOURCE ATTRIBUTE TYPE DESCRIPTION
guest-carts priceMode String Price mode that was active when the cart was created.
guest-carts currency String Currency that was selected when the cart was created.
guest-carts store String Store for which the cart was created.
guest-carts name String Name of the shopping cart.
guest-carts isDefault Boolean Defines whether the cart is default or not.

Totals information

RESOURCE ATTRIBUTE TYPE DESCRIPTION
guest-carts expenseTotal Integer Total amount of expenses (including e.g. shipping costs).
guest-carts discountTotal Integer Total amount of discounts applied to the cart.
guest-carts taxTotal Integer Total amount of taxes to be paid.
guest-carts subTotal Integer Subtotal of the cart.
guest-carts grandTotal Integer Grand total of the cart.

Discount information

RESOURCE ATTRIBUTE TYPE DESCRIPTION
guest-carts displayName String Discount name.
guest-carts code String Discount code applied to the cart.
guest-carts amount Integer Discount amount applied to the cart.

Thresholds

RESOURCE ATTRIBUTE TYPE DESCRIPTION
carts threshold Array Thresholds applied.
carts type String Threshold type.
carts threshold Integer Threshold monetary amount.
carts fee Integer Fee to be paid if the threshold is not reached.
carts deltaWithSubtotal Integer Displays the remaining amount that needs to be added to pass the threshold.
carts message String Message shown to the customer if the threshold is not fulfilled.
RESOURCE ATTRIBUTE TYPE DESCRIPTION
vouchers, cart-rules displayName String Discount name displayed on the Storefront.
vouchers, cart-rules amount Integer Amount of the provided discount.
vouchers, cart-rules code String Discount code.
vouchers, cart-rules discountType String Discount type.
vouchers, cart-rules isExclusive Boolean Discount exclusivity.
vouchers, cart-rules expirationDateTime DateTimeUtc Date and time on which the discount expires.
vouchers, cart-rules discountPromotionAbstractSku String SKU of the products to which the discount applies. If the discount can be applied to any product, the value is null.
vouchers, cart-rules 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.

Possible errors

CODE REASON
101 Cart with given uuid not found.
104 Cart uuid is missing.
109 Anonymous customer unique ID is empty.

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