Add Custom Item to Cart

You will want to add a custom item to the cart to handle things like shipping, taxes and inventory you don't manage with Moltin.

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

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

Custom Cart Items are available via implicit authentication. You should always check each order has the correct details for each item, most importantly, price.

Add Custom Item 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

A list of tax items to apply to this cart item

type

string

custom_item

name

string

The name of the custom item

sku

string

The SKU code to use for the custom item

description

string

A description of the custom item

quantity

integer

The amount of custom items to add to cart

price.amount

integer

The price of the custom item

price.includes_tax

boolean

true if relevant taxes have been included in the price, false if not. Defaults to true

{
    "data": [
        {
            "id": "581db51b-d4df-4aff-855d-e8ddbcf81b0c",
            "type": "custom_item",
            "name": "My Custom Item",
            "description": "My first custom item!",
            "sku": "my-custom-item",
            "image": {
                "mime_type": "",
                "file_name": "",
                "href": ""
            },
            "quantity": 1,
            "manage_stock": false,
            "unit_price": {
                "amount": 10000,
                "currency": "USD",
                "includes_tax": true
            },
            "value": {
                "amount": 10000,
                "currency": "USD",
                "includes_tax": true
            },
            "links": {},
            "meta": {
                "display_price": {
                    "with_tax": {
                        "unit": {
                            "amount": 10000,
                            "currency": "USD",
                            "formatted": "$100.00"
                        },
                        "value": {
                            "amount": 10000,
                            "currency": "USD",
                            "formatted": "$100.00"
                        }
                    },
                    "without_tax": {
                        "unit": {
                            "amount": 10000,
                            "currency": "USD",
                            "formatted": "$100.00"
                        },
                        "value": {
                            "amount": 10000,
                            "currency": "USD",
                            "formatted": "$100.00"
                        }
                    }
                },
                "timestamps": {
                    "created_at": "2018-05-08T10:11:17.871313413Z",
                    "updated_at": "2018-05-08T10:11:17.871313413Z"
                }
            }
        }
    ],
    "meta": {
        "display_price": {
            "with_tax": {
                "amount": 57500,
                "currency": "USD",
                "formatted": "$575.00"
            },
            "without_tax": {
                "amount": 57500,
                "currency": "USD",
                "formatted": "$575.00"
            }
        },
        "timestamps": {
            "created_at": "2018-05-08T10:00:20.171Z",
            "updated_at": "2018-05-08T10:11:17.871313413Z"
        }
    }
}
curl -X POST https://api.moltin.com/v2/carts/:reference/items \
     -H "Authorization: Bearer XXXX" \
     -H "Content-Type: application/json" \
     -d $'{
      "data": {
        "type": "custom_item",
        "name": "My Custom Item",
        "sku": "my-custom-item",
        "description": "My first custom item!",
        "quantity": 1,
        "price": {
          "amount": 10000
        }
      }
    }'

Last updated