Add Product to Cart

Adding a Product to Cart is the most common Cart action. If you wish to add any custom products or promotions, you'll need to do that separately.

  • Any requests to add a product to cart will return a collection of cart items.

  • Tax items may optionally be added with the product, although client credentials must be used to do this. If included, they replace any existing taxes on the product.

  • The product being added to the cart requires a price in the same currency as the cart. The API will return a 400 error if a price is not defined in the correct currency.

Please note that there is a hard limit of up to 100 unique items in a cart at any one time.

There are a number of actions that happen to your inventory when checking out and paying for an order. For more information please be sure to evaluate our detailed article explaining the processes.

Add Product to Cart

POST https://api.moltin.com/v2/carts/:reference/items

Path Parameters

NameTypeDescription

reference

string

A custom reference for this cart created by you

Headers

NameTypeDescription

X-MOLTIN-CURRENCY

string

Specifies the currency to be used for the products in the cart. Your site's default will be used if not specified

Authorization

string

The Bearer token to grant access to the API

Request Body

NameTypeDescription

tax

array

An list of tax items to apply to the cart item

quantity

integer

The amount of products to add to cart

type

string

cart_item

id

string

The ID of the product you wish to add to cart

{
    "data": [
        {
            "id": "8838d444-87f4-411f-9d89-9fc809f0b1cb",
            "type": "cart_item",
            "product_id": "9eda5ba0-4f4a-4074-8547-ccb05d1b5981",
            "name": "Crown",
            "description": "Abstract, sculptural, refined and edgy with a modern twist. Its symmetrical, spoked structure generates a clever geometric presence, which works well in a contemporary environment.",
            "sku": "CWLP100BLK",
            "image": {
                "mime_type": "image/png",
                "file_name": "lamp7-trans.png",
                "href": "https://s3-eu-west-1.amazonaws.com/bkt-svc-files-cmty-api-moltin-com/e8c53cb0-120d-4ea5-8941-ce74dec06038/7cc08cbb-256e-4271-9b01-d03a9fac9f0a.png"
            },
            "quantity": 1,
            "manage_stock": true,
            "unit_price": {
                "amount": 47500,
                "currency": "USD",
                "includes_tax": true
            },
            "value": {
                "amount": 47500,
                "currency": "USD",
                "includes_tax": true
            },
            "links": {
                "product": "https://api.moltin.com/products/9eda5ba0-4f4a-4074-8547-ccb05d1b5981"
            },
            "meta": {
                "display_price": {
                    "with_tax": {
                        "unit": {
                            "amount": 47500,
                            "currency": "USD",
                            "formatted": "47500"
                        },
                        "value": {
                            "amount": 47500,
                            "currency": "USD",
                            "formatted": "475.00"
                        }
                    },
                    "without_tax": {
                        "unit": {
                            "amount": 47500,
                            "currency": "USD",
                            "formatted": "47500"
                        },
                        "value": {
                            "amount": 47500,
                            "currency": "USD",
                            "formatted": "475.00"
                        }
                    }
                },
                "timestamps": {
                    "created_at": "2018-05-08T10:00:20.171620445Z",
                    "updated_at": "2018-05-08T10:00:20.171620445Z"
                }
            }
        }
    ],
    "meta": {
        "display_price": {
            "with_tax": {
                "amount": 47500,
                "currency": "USD",
                "formatted": "475.00"
            },
            "without_tax": {
                "amount": 47500,
                "currency": "USD",
                "formatted": "475.00"
            }
        },
        "timestamps": {
            "created_at": "2018-05-08T10:00:20.171620445Z",
            "updated_at": "2018-05-08T10:00:20.171620445Z"
        }
    }
}
curl -X POST https://api.moltin.com/v2/carts/:reference/items \
     -H "Authorization: Bearer XXXX" \
     -H "Content-Type: application/json" \
     -d $'{
      "data": {
          "id": "df32387b-6ce6-4802-9b90-1126a5c5a54f",
          "type": "cart_item",
          "quantity": 1
        }
      }'

Last updated