Cart
The cart is a crucial component of any e-commerce system. Sleekshop provides a range of endpoints to manage shopping carts efficiently. On this page, we'll explore the different cart endpoints you can use to add, remove, and retrieve cart items.
The cart model
The cart model in Sleekshop contains all the information about the current state of a user's shopping cart. It includes details about the items in the cart, applied coupons, and delivery costs.
Properties
- Name
object
- Type
- string
- Description
Always "cart" for cart objects.
- Name
creation_date
- Type
- string
- Description
The date and time when the cart was created.
- Name
sum
- Type
- number
- Description
The total sum of all items in the cart.
- Name
contents
- Type
- array
- Description
An array of items in the cart.
- Name
coupons
- Type
- object
- Description
Information about applied coupons.
- Name
delivery_costs
- Type
- object
- Description
Information about delivery costs.
Cart item properties
- Name
type
- Type
- string
- Description
The type of the cart item (e.g., "PRODUCT", "FREE_ELEMENT").
- Name
id
- Type
- integer
- Description
The unique identifier of the cart item.
- Name
id_product
- Type
- integer
- Description
The ID of the product (if applicable).
- Name
element_number
- Type
- string
- Description
The element number or SKU.
- Name
quantity
- Type
- number
- Description
The quantity of the item in the cart.
- Name
price
- Type
- number
- Description
The price of a single unit of the item.
- Name
sum_price
- Type
- number
- Description
The total price for this item (price * quantity).
- Name
tax
- Type
- number
- Description
The tax amount for a single unit.
- Name
sum_tax
- Type
- number
- Description
The total tax amount for this item.
- Name
name
- Type
- string
- Description
The name of the item.
- Name
description
- Type
- string
- Description
A description of the item.
- Name
attributes
- Type
- object
- Description
Additional attributes of the item.
Add to cart
This endpoint allows you to add an item to the cart associated with a specific session.
Required attributes
- Name
session
- Type
- string
- Description
A valid session code.
- Name
id_shopobject
- Type
- integer
- Description
The ID of the object you want to add to the cart. Use 0 for FREE_ELEMENTS.
- Name
element_type
- Type
- string
- Description
A valid element type. Options: PRODUCT, PRODUCT_GR, FREE_ELEMENT, FREE_ELEMENT_GR.
- Name
quantity
- Type
- float
- Description
The quantity you want to add.
- Name
price_field
- Type
- string
- Description
The field where the price is stored. For free elements, you can set the price directly.
- Name
name_field
- Type
- string
- Description
The field where the name is stored.
- Name
description_field
- Type
- string
- Description
The field where the description is stored.
- Name
language
- Type
- string
- Description
A valid language code.
- Name
country
- Type
- string
- Description
A valid country code.
Optional attributes
- Name
id_parent_element
- Type
- integer
- Description
The ID of the parent element, if needed. Use 0 when no parent is needed.
- Name
attributes
- Type
- array
- Description
Additional attributes you want to store.
Request
curl https://demo.sleekshop.net/srv/service/ \
-d licence_username='demo_NBSqhrcrhMci15Ir9UWI' \
-d licence_password='s9vmrbwT23B7bmjR4Vmz' \
-d request='add_to_cart' \
-d session=A_VALID_SESSION_CODE \
-d id_shopobject=42 \
-d element_type="PRODUCT" \
-d id_parent_element=0 \
-d quantity=1 \
-d price_field="price" \
-d name_field="name" \
-d description_field="short_description" \
-d language="de_DE" \
-d country="DE"
Response
{
"object": "cart",
"creation_date": "2018-08-09 21:16:15",
"sum": 27.9,
"last_inserted_element_id": 498,
"contents": [
{
"type": "PRODUCT",
"id": 498,
"id_product": 42,
"element_number": "123",
"quantity": 1,
"price": 27.9,
"sum_price": 27.9,
"tax": 4.45462,
"sum_tax": 4.45462,
"name": "Schneehut dunkelblau",
"description": "Warmer und superweicher Schneehut in dunkelblau",
"attributes": {
"sys_tax": {
"name": "sys_tax",
"value": "0.19"
},
// More attributes...
}
}
],
"coupons": {
"sum": 12,
"positions": [
{
"name": "campaign",
"code": "mg7a-c41a-d9h7-i5aa",
"amount": 12,
"used_amount": 12,
"tax": 0.16
}
]
},
"delivery_costs": {
"sum": 0,
"positions": []
}
}
Subtract from cart
This endpoint allows you to decrease the quantity of an item in the cart by one.
Required attributes
- Name
session
- Type
- string
- Description
A valid session string.
- Name
id_element
- Type
- integer
- Description
A valid element ID (set by the cart, not the product ID).
Request
curl https://demo.sleekshop.net/srv/service/ \
-d licence_username='demo_NBSqhrcrhMci15Ir9UWI' \
-d licence_password='s9vmrbwT23B7bmjR4Vmz' \
-d request='sub_from_cart' \
-d session='A_VALID_SESSION_ID' \
-d id_element=A_VALID_ELEMENT_ID
Response
{
"object": "cart",
"creation_date": "2018-08-09 21:16:15",
"sum": 27.9,
"contents": [
// Cart contents...
],
"coupons": {
// Coupon information...
},
"delivery_costs": {
// Delivery cost information...
}
}
Delete from cart
This endpoint allows you to remove an item completely from the cart.
Required attributes
- Name
session
- Type
- string
- Description
A valid session string.
- Name
id_element
- Type
- integer
- Description
A valid element ID (set by the cart, not the product ID).
Request
curl https://demo.sleekshop.net/srv/service/ \
-d licence_username='demo_NBSqhrcrhMci15Ir9UWI' \
-d licence_password='s9vmrbwT23B7bmjR4Vmz' \
-d request='del_from_cart' \
-d session='A_VALID_SESSION_ID' \
-d id_element=A_VALID_ELEMENT_ID
Response
{
"object": "cart",
"creation_date": "2018-08-09 21:16:15",
"sum": 27.9,
"contents": [
// Updated cart contents...
],
"coupons": {
// Coupon information...
},
"delivery_costs": {
// Delivery cost information...
}
}
Clear cart
This endpoint allows you to remove all items from the cart, resulting in an empty cart.
Required attributes
- Name
session
- Type
- string
- Description
A valid session string.
Request
curl https://demo.sleekshop.net/srv/service/ \
-d licence_username='demo_NBSqhrcrhMci15Ir9UWI' \
-d licence_password='s9vmrbwT23B7bmjR4Vmz' \
-d request='clear_cart' \
-d session='A_VALID_SESSION_ID'
Response
{
"object": "cart",
"creation_date": "2022-02-11 03:47:31",
"sum": 0,
"contents": [],
"coupons": {
"sum": 0,
"positions": []
},
"delivery_costs": {
"sum": 0,
"positions": []
}
}
Get cart
This endpoint allows you to retrieve the current state of the cart for a given session.
Required attributes
- Name
session
- Type
- string
- Description
A valid session string.
Request
curl https://demo.sleekshop.net/srv/service/ \
-d licence_username='demo_NBSqhrcrhMci15Ir9UWI' \
-d licence_password='s9vmrbwT23B7bmjR4Vmz' \
-d request='get_cart' \
-d session='A_VALID_SESSION'
Response
{
"object": "cart",
"creation_date": "2018-08-09 21:16:15",
"sum": 27.9,
"contents": [
{
"type": "PRODUCT",
"id": 498,
"id_product": 42,
"element_number": "123",
"quantity": 1,
"price": 27.9,
"sum_price": 27.9,
"tax": 4.45462,
"sum_tax": 4.45462,
"name": "Schneehut dunkelblau",
"description": "Warmer und superweicher Schneehut in dunkelblau",
"attributes": {
// Product attributes...
}
}
],
"coupons": {
"sum": 12,
"positions": [
{
"name": "campaign",
"code": "mg7a-c41a-d9h7-i5aa",
"amount": 12,
"used_amount": 12,
"tax": 0.16
}
]
},
"delivery_costs": {
"sum": 0,
"positions": []
}
}