import HenrySDK from '@henrylabs/sdk';
const client = new HenrySDK({
apiKey: process.env['HENRY_SDK_API_KEY'], // This is the default and can be omitted
});
const response = await client.cart.items.add({
productsDetails: [
{
name: "Men's Trail Runners",
price: '100',
productLink:
'https://www.on.com/en-us/products/cloud-6-versa-m-3mf1004/mens/black-eclipse-shoes-3MF10040106',
quantity: 1,
},
],
'x-user-id': 'x-user-id',
});
console.log(response.message);{
"success": true,
"status": "<string>",
"message": "<string>",
"data": {
"added_products": [
{
"productId": "<string>",
"name": "<string>",
"price": "<string>",
"quantity": 123
}
],
"updated_products": [
{
"productId": "<string>",
"name": "<string>",
"price": "<string>",
"quantity": 123,
"previousQuantity": 123,
"addedQuantity": 123
}
],
"cart_summary": {
"total_items": 123,
"total_unique_products": 123
},
"variant_checks": [
{
"productId": "<string>",
"variantCheckRequestId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"status": "<string>"
}
]
}
}Adds product data to existing cart or create a new one.
import HenrySDK from '@henrylabs/sdk';
const client = new HenrySDK({
apiKey: process.env['HENRY_SDK_API_KEY'], // This is the default and can be omitted
});
const response = await client.cart.items.add({
productsDetails: [
{
name: "Men's Trail Runners",
price: '100',
productLink:
'https://www.on.com/en-us/products/cloud-6-versa-m-3mf1004/mens/black-eclipse-shoes-3MF10040106',
quantity: 1,
},
],
'x-user-id': 'x-user-id',
});
console.log(response.message);{
"success": true,
"status": "<string>",
"message": "<string>",
"data": {
"added_products": [
{
"productId": "<string>",
"name": "<string>",
"price": "<string>",
"quantity": 123
}
],
"updated_products": [
{
"productId": "<string>",
"name": "<string>",
"price": "<string>",
"quantity": 123,
"previousQuantity": 123,
"addedQuantity": 123
}
],
"cart_summary": {
"total_items": 123,
"total_unique_products": 123
},
"variant_checks": [
{
"productId": "<string>",
"variantCheckRequestId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"status": "<string>"
}
]
}
}1Show child attributes
Product name
1"Men's Trail Runners"
Product price
1"100"
Quantity
1
Product link
"https://www.on.com/en-us/products/cloud-6-versa-m-3mf1004/mens/black-eclipse-shoes-3MF10040106"
Product Id
1"P01145AC2"
Affiliate product link (if provided, will be used instead of productLink for order fulfillment)
"https://www.on.com/en-us/products/cloud-6-versa-m-3mf1004/mens/black-eclipse-shoes-3MF10040106?ref=affiliate123"
Product image link (thumbnail)
"https://images.ctfassets.net/hnk2vsx53n6l/2xi62H2BswFpVK0SjUmhXM/0d4a4bb14915c9a5d3228df45c774629/c36d3fd00cf91ec9fb5ff4bc4d4a0093cccbe8cd.png?w=192&h=192&fm=avif&f=center&fit=fill&q=80"
Whether to check variant availability after adding to cart. If true, variant check requests will be created for products with metadata and requestIds returned.
false
Product added to the cart successfully.
Show child attributes