Glue API: Retrieve discounts in customer carts

Edit on GitHub

This document describes how to retrieve cart rules, vouchers, and promotional items in customer carts. For full information on the endpoint, see Retrieve customer carts.

Installation

For details on the modules that provide the API functionality and how to install them, see the following docs:

Retrieve customer’s carts

To retrieve a customer’s carts, send the following request:

GET /customers/{{customerId}}/carts

Note

Alternatively, you can retrieve all carts belonging to a customer through the /carts endpoint. For details, see Retrieve discounts in carts of registered users.

PATH PARAMETER DESCRIPTION
{{customerId}} The Customer’s unique ID to retrieve the carts of. To get it, retrieve a customer or create a customer.

Request

HEADER KEY HEADER VALUE REQUIRED DESCRIPTION
Authorization string Alphanumeric string that authorizes the customer to send requests to protected resources. Get it by authenticating as a customer.
QUERY PARAMETER DESCRIPTION EXEMPLARY VALUES
include Adds resource relationships to the request.
  • cart-rules
  • promotional-items
  • vouchers
REQUEST USAGE
GET https://glue.mysprykershop.com/customers/DE--1/?include=cart-rules Retrieve all carts of a user with cart rules.
GET https://glue.mysprykershop.com/customers/DE--1/?include=vouchers Retrieve all carts of a user with information about applied vouchers.
GET https://glue.mysprykershop.com/customers/DE--1/?include=promotional-items Retrieve information about promotional items for the cart.

Response

Response sample: retrieve customer's carts with the cart rules included
{
    "data": [
        {
            "type": "carts",
            "id": "59743e37-0182-5153-9935-77106741a9d2",
            "attributes": {
                "priceMode": "GROSS_MODE",
                "currency": "EUR",
                "store": "DE",
                "name": "Purchases",
                "isDefault": true,
                "totals": {
                    "expenseTotal": null,
                    "discountTotal": null,
                    "taxTotal": null,
                    "subtotal": null,
                    "grandTotal": null
                },
                "discounts": []
            },
            "links": {
                "self": "https://glue.mysprykershop.com/carts/59743e37-0182-5153-9935-77106741a9d2"
            }
        },
        {
            "type": "carts",
            "id": "2fd32609-b6b0-5993-9254-8d2f271941e4",
            "attributes": {
                "priceMode": "GROSS_MODE",
                "currency": "EUR",
                "store": "DE",
                "name": "My Cart",
                "isDefault": false,
                "totals": {
                    "expenseTotal": 0,
                    "discountTotal": 2965,
                    "taxTotal": 4261,
                    "subtotal": 29651,
                    "grandTotal": 26686
                },
                "discounts": [
                    {
                        "displayName": "10% Discount for all orders above",
                        "amount": 2965,
                        "code": null
                    }
                ]
            },
            "links": {
                "self": "https://glue.mysprykershop.com/carts/2fd32609-b6b0-5993-9254-8d2f271941e4"
            },
            "relationships": {
                "cart-rules": {
                    "data": [
                        {
                            "type": "cart-rules",
                            "id": "1"
                        }
                    ]
                }
            }
        },
        {
            "type": "carts",
            "id": "2b72635a-9363-56f5-9ba7-55631b8ad71e",
            "attributes": {
                "priceMode": "GROSS_MODE",
                "currency": "EUR",
                "store": "DE",
                "name": "New",
                "isDefault": false,
                "totals": {
                    "expenseTotal": 0,
                    "discountTotal": 10206,
                    "taxTotal": 14666,
                    "subtotal": 102063,
                    "grandTotal": 91857
                },
                "discounts": [
                    {
                        "displayName": "10% Discount for all orders above",
                        "amount": 10206,
                        "code": null
                    }
                ]
            },
            "links": {
                "self": "https://glue.mysprykershop.com/carts/2b72635a-9363-56f5-9ba7-55631b8ad71e"
            },
            "relationships": {
                "cart-rules": {
                    "data": [
                        {
                            "type": "cart-rules",
                            "id": "1"
                        }
                    ]
                }
            }
        }
    ],
    "links": {
        "self": "https://glue.mysprykershop.com/carts?include=cart-rules"
    },
    "included": [
        {
            "type": "cart-rules",
            "id": "1",
            "attributes": {
                "amount": 10206,
                "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 customer's carts with the information on vouchers included
{
    "data": [
        {
            "type": "carts",
            "id": "976af32f-80f6-5f69-878f-4ea549ee0830",
            "attributes": {
                "priceMode": "GROSS_MODE",
                "currency": "EUR",
                "store": "DE",
                "totals": {
                    "expenseTotal": 0,
                    "discountTotal": 1663,
                    "taxTotal": 5046,
                    "subtotal": 33265,
                    "grandTotal": 31602,
                    "priceToPay": 31602
                },
                "discounts": [
                    {
                        "displayName": "5% discount on all white products",
                        "amount": 1663,
                        "code": null
                    }
                ]
            },
            "links": {
                "self": "https://glue.mysprykershop.com/carts/976af32f-80f6-5f69-878f-4ea549ee0830?include=vouchers"
            },
            "relationships": {
                "vouchers": {
                    "data": [
                        {
                            "type": "vouchers",
                            "id": "sprykerya1y"
                        }
                    ]
                }
            }
        }
    ],
    "links": {
        "self": "https://glue.mysprykershop.com/carts?include=vouchers"
    },
    "included": [
        {
            "type": "vouchers",
            "id": "sprykerya1y",
            "attributes": {
                "amount": 1663,
                "code": "sprykerya1y",
                "discountType": "voucher",
                "displayName": "5% discount on all white products",
                "isExclusive": false,
                "expirationDateTime": "2021-02-28 00:00:00.000000",
                "discountPromotionAbstractSku": null,
                "discountPromotionQuantity": null
            },
            "links": {
                "self": "https://glue.mysprykershop.com/carts/976af32f-80f6-5f69-878f-4ea549ee0830/cart-codes/sprykerya1y"
            }
        }
    ]
}
Response sample: retrieve customer's carts withe the information on promotional items included
{
    "data": [
        {
            "type": "carts",
            "id": "e877356a-5d8f-575e-aacc-c790eeb20a27",
            "attributes": {
                "priceMode": "GROSS_MODE",
                "currency": "EUR",
                "store": "DE",
                "name": "Everyday purchases",
                "isDefault": true,
                "totals": {
                    "expenseTotal": 0,
                    "discountTotal": 17352,
                    "taxTotal": 19408,
                    "subtotal": 173517,
                    "grandTotal": 156165,
                    "priceToPay": 56165
                },
                "discounts": [
                    {
                        "displayName": "10% Discount for all orders above",
                        "amount": 17352,
                        "code": null
                    }
                ]
            },
            "links": {
                "self": "https://glue.mysprykershop.com/carts/e877356a-5d8f-575e-aacc-c790eeb20a27"
            },
            "relationships": {
                "promotional-items": {
                    "data": [
                        {
                            "type": "promotional-items",
                            "id": "bfc600e1-5bf1-50eb-a9f5-a37deb796f8a"
                        }
                    ]
                }
            }
        }
    ],
    "links": {
        "self": "https://glue.mysprykershop.com/carts?include=promotional-items"
    },
    "included": [
        {
            "type": "promotional-items",
            "id": "bfc600e1-5bf1-50eb-a9f5-a37deb796f8a",
            "attributes": {
                "sku": "112",
                "quantity": 2
            },
            "links": {
                "self": "https://glue.mysprykershop.com/promotional-items/bfc600e1-5bf1-50eb-a9f5-a37deb796f8a"
            }
        }
    ]
}

General cart information

RESOURCE ATTRIBUTE TYPE DESCRIPTION
carts currency String Currency that was selected when the cart was created.
carts isDefault Boolean Specifies whether the cart is the default one for the customer. The field is available in multi-cart environments only.
carts name String Specifies a cart name. The field is available in multi-cart environments only.
carts priceMode String Price mode that was active when the cart was created.
carts store String Store for which the cart was created.

Discount information

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

Totals

RESOURCE ATTRIBUTE TYPE DESCRIPTION
carts expenseTotal String Total amount of expenses (including, e.g., shipping costs).
carts discountTotal Integer Total amount of discounts applied to the cart.
carts taxTotal Integer Total amount of taxes to be paid.
carts subTotal Integer Subtotal of the cart.
carts grandTotal Integer Grand total of the cart.
carts priceToPay Integer Total price of the cart to pay after discounts.
carts selectedProductOptions array List of attributes describing the product options that were added to cart with the product.

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.
INCLUDED RESOURCE ATTRIBUTE TYPE DESCRIPTION
promotional-items id String The unique ID of the promotional item. The ID can be used to apply the promotion to the given purchase.
promotional-items sku String The SKU of the promoted abstract product.
promotional-items quantity Integer Specifies how many promotions can be applied to the given purchase.
product-options optionGroupName String The name of the group to which the option belongs.
product-options sku String The SKU of the product option.
product-options optionName String The product option’s name.
product-options price Integer The product option price in cents.
product-options currencyIsoCode String The ISO 4217 code of the currency in which the product option price is specified.

Possible errors

CODE REASON
001 Access token is invalid.
002 Access token is missing.
402 Customer with the specified ID was not found.
802 Request is unauthorized.

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