Glue API: Add items with discounts to carts of registered users
Edit on GitHubThis document describes how to add items with discounts to carts of registered users. For full information on the endpoint, see Manage items in carts of registered users.
Installation
For detailed information on the modules that provide the API’s functionality and related installation instructions, see:
Add items to a registered user’s cart
To add items to a cart, send the request:
POST
carts/{{cart_uuid}}/items
PATH PARAMETER | DESCRIPTION |
---|---|
{{cart_uuid}} | The unique ID of a cart. Create a cart) or Retrieve a registered user’s carts to get it. |
Request
HEADER KEY | HEADER VALUE | REQUIRED | DESCRIPTION |
---|---|---|---|
Authorization | string | ✓ | An alphanumeric string that authorizes the customer to send requests to protected resources. Get it by authenticating as a customer. |
QUERY PARAMETER | DESCRIPTION | POSSIBLE VALUE |
---|---|---|
include | Adds resource relationships to the request. |
|
Request sample with cart rules
POST https://glue.mysprykershop.com/carts/976af32f-80f6-5f69-878f-4ea549ee0830/items?include=cart-rules
{
"data": {
"type": "items",
"attributes": {
"sku": "077_24584210",
"quantity": "10"
}
}
}
Request sample with vouchers
POST https://glue.mysprykershop.com/carts/976af32f-80f6-5f69-878f-4ea549ee0830/items?include=vouchers
{
"data": {
"type": "items",
"attributes": {
"sku": "066_23294028",
"quantity": "1"
}
}
}
Request sample with a promotional item and cart rules
To add the promotional product to the cart, make sure that the cart fulfills the cart rules for the promotional item.
POST https://glue.myspsrykershop.com/carts/1ce91011-8d60-59ef-9fe0-4493ef3628b2/items?include=cart-rules
{
"data": {
"type": "items",
"attributes": {
"sku": "112_306918001",
"quantity": "1",
"idPromotionalItem": "bfc600e1-5bf1-50eb-a9f5-a37deb796f8a"
}
}
}
ATTRIBUTE | TYPE | REQUIRED | DESCRIPTION |
---|---|---|---|
sku | String | ✓ | Specifies the SKU of the concrete product to add to the cart. |
quantity | String | ✓ | Specifies the number of items to place on the guest cart. If you add a promotional item and the number of products exceeds the number of promotions, the exceeding items will be added without promotional benefits. |
idPromotionalItem | String | The ID of the promotional item. Specify the ID to apply the promotion benefits. |
Response
Response sample with cart rules
{
"data": {
"type": "carts",
"id": "976af32f-80f6-5f69-878f-4ea549ee0830",
"attributes": {
"priceMode": "GROSS_MODE",
"currency": "EUR",
"store": "DE",
"totals": {
"expenseTotal": 0,
"discountTotal": 14554,
"taxTotal": 20914,
"subtotal": 145540,
"grandTotal": 130986,
"priceToPay": 130986
},
"discounts": [
{
"displayName": "10% Discount for all orders above",
"amount": 14554,
"code": null
}
],
"thresholds": []
},
"links": {
"self": "https://glue.mysprykershop.com/carts/976af32f-80f6-5f69-878f-4ea549ee0830"
},
"relationships": {
"cart-rules": {
"data": [
{
"type": "cart-rules",
"id": "1"
}
]
}
}
},
"included": [
{
"type": "cart-rules",
"id": "1",
"attributes": {
"amount": 14554,
"code": null,
"discountType": "cart_rule",
"displayName": "10% Discount for all orders above",
"isExclusive": false,
"expirationDateTime": "2021-02-27 00:00:00.000000",
"discountPromotionAbstractSku": null,
"discountPromotionQuantity": null
},
"links": {
"self": "https://glue.mysprykershop.com/cart-rules/1"
}
},
{
"type": "items",
"id": "077_24584210",
"attributes": {
"sku": "077_24584210",
"quantity": "10",
"groupKey": "077_24584210",
"abstractSku": "077",
"amount": null,
"calculations": {
"unitPrice": 14554,
"sumPrice": 145540,
"taxRate": 19,
"unitNetPrice": 0,
"sumNetPrice": 0,
"unitGrossPrice": 14554,
"sumGrossPrice": 145540,
"unitTaxAmountFullAggregation": 2091,
"sumTaxAmountFullAggregation": 20914,
"sumSubtotalAggregation": 145540,
"unitSubtotalAggregation": 14554,
"unitProductOptionPriceAggregation": 0,
"sumProductOptionPriceAggregation": 0,
"unitDiscountAmountAggregation": 1455,
"sumDiscountAmountAggregation": 14554,
"unitDiscountAmountFullAggregation": 1455,
"sumDiscountAmountFullAggregation": 14554,
"unitPriceToPayAggregation": 13099,
"sumPriceToPayAggregation": 130986
},
"selectedProductOptions": []
},
"links": {
"self": "https://glue.mysprykershop.com/carts/976af32f-80f6-5f69-878f-4ea549ee0830/items/077_24584210"
}
}
]
}
Response sample with vouchers
{
"data": {
"type": "carts",
"id": "976af32f-80f6-5f69-878f-4ea549ee0830",
"attributes": {
"priceMode": "GROSS_MODE",
"currency": "EUR",
"store": "DE",
"totals": {
"expenseTotal": 0,
"discountTotal": 25766,
"taxTotal": 25407,
"subtotal": 184893,
"grandTotal": 159127,
"priceToPay": 159127
},
"discounts": [
{
"displayName": "5% discount on all white products",
"amount": 7277,
"code": null
},
{
"displayName": "10% Discount for all orders above",
"amount": 18489,
"code": null
}
],
"thresholds": []
},
"links": {
"self": "https://glue.mysprykershop.com/carts/976af32f-80f6-5f69-878f-4ea549ee0830"
},
"relationships": {
"vouchers": {
"data": [
{
"type": "vouchers",
"id": "sprykercu2d"
}
]
}
}
},
"included": [
{
"type": "vouchers",
"id": "sprykercu2d",
"attributes": {
"amount": 7277,
"code": "sprykercu2d",
"discountType": "voucher",
"displayName": "5% discount on all white products",
"isExclusive": false,
"expirationDateTime": "2021-02-27 00:00:00.000000",
"discountPromotionAbstractSku": null,
"discountPromotionQuantity": null
},
"links": {
"self": "https://glue.mysprykershop.com/carts/976af32f-80f6-5f69-878f-4ea549ee0830/cart-codes/sprykercu2d"
}
},
{
"type": "items",
"id": "077_24584210",
"attributes": {
"sku": "077_24584210",
"quantity": "10",
"groupKey": "077_24584210",
"abstractSku": "077",
"amount": null,
"calculations": {
"unitPrice": 14554,
"sumPrice": 145540,
"taxRate": 19,
"unitNetPrice": 0,
"sumNetPrice": 0,
"unitGrossPrice": 14554,
"sumGrossPrice": 145540,
"unitTaxAmountFullAggregation": 1975,
"sumTaxAmountFullAggregation": 19752,
"sumSubtotalAggregation": 145540,
"unitSubtotalAggregation": 14554,
"unitProductOptionPriceAggregation": 0,
"sumProductOptionPriceAggregation": 0,
"unitDiscountAmountAggregation": 2183,
"sumDiscountAmountAggregation": 21831,
"unitDiscountAmountFullAggregation": 2183,
"sumDiscountAmountFullAggregation": 21831,
"unitPriceToPayAggregation": 12371,
"sumPriceToPayAggregation": 123709
},
"selectedProductOptions": []
},
"links": {
"self": "https://glue.mysprykershop.com/carts/976af32f-80f6-5f69-878f-4ea549ee0830/items/077_24584210"
}
},
{
"type": "items",
"id": "066_23294028",
"attributes": {
"sku": "066_23294028",
"quantity": "1",
"groupKey": "066_23294028",
"abstractSku": "066",
"amount": null,
"calculations": {
"unitPrice": 39353,
"sumPrice": 39353,
"taxRate": 19,
"unitNetPrice": 0,
"sumNetPrice": 0,
"unitGrossPrice": 39353,
"sumGrossPrice": 39353,
"unitTaxAmountFullAggregation": 5655,
"sumTaxAmountFullAggregation": 5655,
"sumSubtotalAggregation": 39353,
"unitSubtotalAggregation": 39353,
"unitProductOptionPriceAggregation": 0,
"sumProductOptionPriceAggregation": 0,
"unitDiscountAmountAggregation": 3935,
"sumDiscountAmountAggregation": 3935,
"unitDiscountAmountFullAggregation": 3935,
"sumDiscountAmountFullAggregation": 3935,
"unitPriceToPayAggregation": 35418,
"sumPriceToPayAggregation": 35418
},
"selectedProductOptions": []
},
"links": {
"self": "https://glue.mysprykershop.com/carts/976af32f-80f6-5f69-878f-4ea549ee0830/items/066_23294028"
}
}
]
}
Response sample: adding a promotional item without cart-rules relationship
{
"data": {
"type": "carts",
"id": "1ce91011-8d60-59ef-9fe0-4493ef3628b2",
"attributes": {
"priceMode": "GROSS_MODE",
"currency": "EUR",
"store": "DE",
"name": "My Cart",
"isDefault": true,
"totals": {
"expenseTotal": 0,
"discountTotal": 13192,
"taxTotal": 15107,
"subtotal": 113207,
"grandTotal": 100015
},
"discounts": [
{
"displayName": "For every purchase above certain value depending on the currency and net/gross price. you get this promotional product for free",
"amount": 2079,
"code": null
},
{
"displayName": "10% Discount for all orders above",
"amount": 11113,
"code": null
}
],
"thresholds": []
},
"links": {
"self": "https://glue.mysprykershop.com/carts/1ce91011-8d60-59ef-9fe0-4493ef3628b2"
}
}
}
Response sample: adding a promotional item with cart-rules relationship
{
"data": {
"type": "carts",
"id": "1ce91011-8d60-59ef-9fe0-4493ef3628b2",
"attributes": {
"priceMode": "GROSS_MODE",
"currency": "EUR",
"store": "DE",
"name": "My Cart",
"isDefault": true,
"totals": {
"expenseTotal": 0,
"discountTotal": 13192,
"taxTotal": 15107,
"subtotal": 113207,
"grandTotal": 100015
},
"discounts": [
{
"displayName": "For every purchase above certain value depending on the currency and net/gross price. you get this promotional product for free",
"amount": 2079,
"code": null
},
{
"displayName": "10% Discount for all orders above",
"amount": 11113,
"code": null
}
],
"thresholds": []
},
"links": {
"self": "https://glue.mysprykershop.com/carts/1ce91011-8d60-59ef-9fe0-4493ef3628b2"
},
"relationships": {
"cart-rules": {
"data": [
{
"type": "cart-rules",
"id": "6"
},
{
"type": "cart-rules",
"id": "1"
}
]
}
}
},
"included": [
{
"type": "items",
"id": "134_29759322",
"attributes": {
"sku": "134_29759322",
"quantity": "1",
"groupKey": "134_29759322",
"abstractSku": "134",
"amount": null,
"calculations": {
"unitPrice": 1879,
"sumPrice": 1879,
"taxRate": 19,
"unitNetPrice": 0,
"sumNetPrice": 0,
"unitGrossPrice": 1879,
"sumGrossPrice": 1879,
"unitTaxAmountFullAggregation": 270,
"sumTaxAmountFullAggregation": 270,
"sumSubtotalAggregation": 1879,
"unitSubtotalAggregation": 1879,
"unitProductOptionPriceAggregation": 0,
"sumProductOptionPriceAggregation": 0,
"unitDiscountAmountAggregation": 188,
"sumDiscountAmountAggregation": 188,
"unitDiscountAmountFullAggregation": 188,
"sumDiscountAmountFullAggregation": 188,
"unitPriceToPayAggregation": 1691,
"sumPriceToPayAggregation": 1691
},
"salesUnit": null,
"selectedProductOptions": []
},
"links": {
"self": "https://glue.mysprykershop.com/carts/1ce91011-8d60-59ef-9fe0-4493ef3628b2/items/134_29759322"
}
},
{
"type": "items",
"id": "118_29804739",
"attributes": {
"sku": "118_29804739",
"quantity": "1",
"groupKey": "118_29804739",
"abstractSku": "118",
"amount": null,
"calculations": {
"unitPrice": 6000,
"sumPrice": 6000,
"taxRate": 0,
"unitNetPrice": 0,
"sumNetPrice": 0,
"unitGrossPrice": 6000,
"sumGrossPrice": 6000,
"unitTaxAmountFullAggregation": 0,
"sumTaxAmountFullAggregation": 0,
"sumSubtotalAggregation": 6000,
"unitSubtotalAggregation": 6000,
"unitProductOptionPriceAggregation": 0,
"sumProductOptionPriceAggregation": 0,
"unitDiscountAmountAggregation": 600,
"sumDiscountAmountAggregation": 600,
"unitDiscountAmountFullAggregation": 600,
"sumDiscountAmountFullAggregation": 600,
"unitPriceToPayAggregation": 5400,
"sumPriceToPayAggregation": 5400
},
"salesUnit": null,
"selectedProductOptions": []
},
"links": {
"self": "https://glue.mysprykershop.com/carts/1ce91011-8d60-59ef-9fe0-4493ef3628b2/items/118_29804739"
}
},
{
"type": "items",
"id": "139_24699831",
"attributes": {
"sku": "139_24699831",
"quantity": "1",
"groupKey": "139_24699831",
"abstractSku": "139",
"amount": null,
"calculations": {
"unitPrice": 3454,
"sumPrice": 3454,
"taxRate": 19,
"unitNetPrice": 0,
"sumNetPrice": 0,
"unitGrossPrice": 3454,
"sumGrossPrice": 3454,
"unitTaxAmountFullAggregation": 496,
"sumTaxAmountFullAggregation": 496,
"sumSubtotalAggregation": 3454,
"unitSubtotalAggregation": 3454,
"unitProductOptionPriceAggregation": 0,
"sumProductOptionPriceAggregation": 0,
"unitDiscountAmountAggregation": 345,
"sumDiscountAmountAggregation": 345,
"unitDiscountAmountFullAggregation": 345,
"sumDiscountAmountFullAggregation": 345,
"unitPriceToPayAggregation": 3109,
"sumPriceToPayAggregation": 3109
},
"salesUnit": null,
"selectedProductOptions": []
},
"links": {
"self": "https://glue.mysprykershop.com/carts/1ce91011-8d60-59ef-9fe0-4493ef3628b2/items/139_24699831"
}
},
{
"type": "items",
"id": "136_24425591",
"attributes": {
"sku": "136_24425591",
"quantity": 3,
"groupKey": "136_24425591",
"abstractSku": "136",
"amount": null,
"calculations": {
"unitPrice": 33265,
"sumPrice": 99795,
"taxRate": 19,
"unitNetPrice": 0,
"sumNetPrice": 0,
"unitGrossPrice": 33265,
"sumGrossPrice": 99795,
"unitTaxAmountFullAggregation": 4780,
"sumTaxAmountFullAggregation": 14341,
"sumSubtotalAggregation": 99795,
"unitSubtotalAggregation": 33265,
"unitProductOptionPriceAggregation": 0,
"sumProductOptionPriceAggregation": 0,
"unitDiscountAmountAggregation": 3327,
"sumDiscountAmountAggregation": 9980,
"unitDiscountAmountFullAggregation": 3327,
"sumDiscountAmountFullAggregation": 9980,
"unitPriceToPayAggregation": 29938,
"sumPriceToPayAggregation": 89815
},
"salesUnit": null,
"selectedProductOptions": []
},
"links": {
"self": "https://glue.mysprykershop.com/carts/1ce91011-8d60-59ef-9fe0-4493ef3628b2/items/136_24425591"
}
},
{
"type": "items",
"id": "112_306918001-promotion-1",
"attributes": {
"sku": "112_306918001",
"quantity": "1",
"groupKey": "112_306918001-promotion-1",
"abstractSku": "112",
"amount": null,
"calculations": {
"unitPrice": 2079,
"sumPrice": 2079,
"taxRate": 0,
"unitNetPrice": 0,
"sumNetPrice": 0,
"unitGrossPrice": 2079,
"sumGrossPrice": 2079,
"unitTaxAmountFullAggregation": 0,
"sumTaxAmountFullAggregation": 0,
"sumSubtotalAggregation": 2079,
"unitSubtotalAggregation": 2079,
"unitProductOptionPriceAggregation": 0,
"sumProductOptionPriceAggregation": 0,
"unitDiscountAmountAggregation": 2079,
"sumDiscountAmountAggregation": 2079,
"unitDiscountAmountFullAggregation": 2079,
"sumDiscountAmountFullAggregation": 2079,
"unitPriceToPayAggregation": 0,
"sumPriceToPayAggregation": 0
},
"salesUnit": null,
"selectedProductOptions": []
},
"links": {
"self": "https://glue.mysprykershop.com/carts/1ce91011-8d60-59ef-9fe0-4493ef3628b2/items/112_306918001-promotion-1"
}
},
{
"type": "cart-rules",
"id": "6",
"attributes": {
"amount": 2079,
"code": null,
"discountType": "cart_rule",
"displayName": "For every purchase above certain value depending on the currency and net/gross price. you get this promotional product for free",
"isExclusive": false,
"expirationDateTime": "2020-12-31 00:00:00.000000",
"discountPromotionAbstractSku": "112",
"discountPromotionQuantity": 2
},
"links": {
"self": "https://glue.mysprykershop.com/cart-rules/6"
}
},
{
"type": "cart-rules",
"id": "1",
"attributes": {
"amount": 11113,
"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"
}
}
]
}
ATTRIBUTE | TYPE | DESCRIPTION |
---|---|---|
sku | String | Product SKU. |
quantity | Integer | Quantity of the given product in the cart. |
groupKey | String | Unique item identifier. The value is generated based on product properties. |
abstractSku | String | Unique identifier of the abstract product owning this concrete product. |
amount | Integer | Amount of the products in the cart. |
unitPrice | Integer | Single item price without assuming if it is net or gross. This value should be used everywhere the price is displayed. It allows switching tax mode without side effects. |
sumPrice | Integer | Sum of all items prices calculated. |
taxRate | Integer | Current tax rate in per cent. |
unitNetPrice | Integer | Single item net price. |
sumNetPrice | Integer | Sum of prices of all items. |
unitGrossPrice | Integer | Single item gross price. |
sumGrossPrice | Integer | Sum of items gross price. |
unitTaxAmountFullAggregation | Integer | Total tax amount for a given item with additions. |
sumTaxAmountFullAggregation | Integer | Total tax amount for a given sum of items with additions. |
sumSubtotalAggregation | Integer | Sum of subtotals of the items. |
unitSubtotalAggregation | Integer | Subtotal for the given item. |
unitProductOptionPriceAggregation | Integer | Item total product option price. |
sumProductOptionPriceAggregation | Integer | Item total of product options for the given sum of items. |
unitDiscountAmountAggregation | Integer | Item total discount amount. |
sumDiscountAmountAggregation | Integer | Sum of Item total discount amount. |
unitDiscountAmountFullAggregation | Integer | Sum total discount amount with additions. |
sumDiscountAmountFullAggregation | Integer | Item total discount amount with additions. |
unitPriceToPayAggregation | Integer | Item total price to pay after discounts with additions. |
sumPriceToPayAggregation | Integer | Sum of the prices to pay (after discounts). |
salesUnit | Object | List of attributes defining the sales unit to be used for item amount calculation. |
salesUnit.id | Integer | Numeric value the defines the sales units to calculate the item amount in. |
salesUnit.amount | Integer | Amount of product in the defined sales units. |
selectedProductOptions | array | List of attributes describing the product options that were added to cart with the product. |
selectedProductOptions.optionGroupName | String | Name of the group to which the option belongs. |
selectedProductOptions.sku | String | SKU of the product option. |
selectedProductOptions.optionName | String | Product option name. |
selectedProductOptions.price | Integer | Product option price in cents. |
selectedProductOptions.currencyIsoCode | String | ISO 4217 code of the currency in which the product option price is specified. |
ATTRIBUTE | TYPE | DESCRIPTION |
---|---|---|
type | String | Threshold type. |
threshold | Integer | Threshold monetary amount. |
fee | Integer | Fee to be paid if the threshold is not reached. |
deltaWithSubtotal | Integer | Displays the remaining amount that needs to be added to pass the threshold. |
message | String | Message shown to the customer if the threshold is not fulfilled. |
INCLUDED RESOURCE | ATTRIBUTE | TYPE | DESCRIPTION |
---|---|---|---|
items, bundle-items, bundled-items | sku | String | Unique identifier of the product that was added to the cart. |
items, bundle-items, bundled-items | quantity | Integer | Quantity of the product that was added to the cart. |
items, bundle-items, bundled-items | groupKey | String | Unique identifier of product as a cart item. |
items, bundle-items, bundled-items | abstractSku | String | Unique identifier of the abstract product that owns the concrete product. |
product-options | optionGroupName | String | Name of the group to which the option belongs. |
product-options | sku | String | SKU of the product option. |
product-options | optionName | String | Product option name. |
product-options | price | Integer | Product option price in cents. |
product-options | currencyIsoCode | String | ISO 4217 code of the currency in which the product option price is specified. |
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 . |
For the attributes of the other included resources, see the docs:
Possible errors
CODE | REASON |
---|---|
001 | Access token is incorrect. |
002 | Access token is missing. |
003 | Failed to log in the user. |
101 | Cart with given uuid is not found. |
102 | Failed to add an item to a cart. |
103 | Item with the given group key is not found in the cart. |
104 | Cart uuid is missing. |
107 | Failed to create a cart. |
110 | Customer already has a cart. |
112 | Store data is invalid. |
113 | Cart item cannot be added. |
115 | Unauthorized cart action. |
116 | Currency is missing. |
117 | Currency is incorrect. |
118 | Price mode is missing. |
119 | Price mode is incorrect. |
To view generic errors that originate from the Glue Application, see Reference information: GlueApplication errors.
Thank you!
For submitting the form