Glue API: Retrieve gift cards in guest carts

Edit on GitHub

This document describes how to retrieve gift cards in guest carts using Glue API. To retrieve full information about guest carts, see Manage guest carts.

Installation

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

Retrieve a guest cart

To retrieve a guest cart, send the 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}} Unique identifier 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 Guest user’s unique identifier. 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.
  • guest-cart-items
  • cart-rules
  • promotional-items
  • gift-cards
  • vouchers
  • product-options
  • sales-units
  • product-measurement-units
  • product-labels

GET https://glue.mysprykershop.com/guest-carts?include=gift-cards,vouchers: Retrieve a guest cart with information about the gift cards applied.

Response sample: add items with gift cards to a guest cart
{
    "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": 93203
                },
                "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": {
                "gift-cards": {
                    "data": [
                        {
                            "type": "gift-cards",
                            "id": "GC-Z9FYJRK3-20"
                        }
                    ]
                }
            }
        }
    ],
    "links": {
        "self": "https://glue.mysprykershop.com/cart-codes?include=gift-cards"
    },
    "included": [
        {
            "type": "gift-cards",
            "id": "GC-Z9FYJRK3-20",
            "attributes": {
                "code": "GC-Z9FYJRK3-20",
                "name": "Gift Card 30",
                "value": 3000,
                "currencyIsoCode": "EUR",
                "actualValue": 3000,
                "isActive": true
            },
            "links": {
                "self": "https://glue.mysprykershop.com/guest-carts/f8782b6c-848d-595e-b3f7-57374f1ff6d7/cart-codes/GC-Z9FYJRK3-20"
            }
        }
    ]
}

General Cart Information

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

Totals Information

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

Discount Information

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

For the attributes of guest cart items, see Managing gift cards of guest users.

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.