Block Client API
AddProductToCart1
Add the given product variant to the current cart.
Method | postMessage |
---|---|
Message Data | { "bubblehouseBlockClientCall": "AddProductToCart1", ... } |
In case your store uses vendibles (products redeemed for points) or free samples (products added to orders as a free bonus), this call is used to add those products to cart for custom and headless stores.
You don't always need to implement this call. We automatically handle supported online stores that provide a first-party Cart API, a prime example being non-headless Shopify (i.e. non-Hydrogen). In those case, do not impement AddProductToCart call unless Bubblehouse team tells you to.
Query Parameters
instance
stringrequiredBlock instance identifier passed to the Blocks API.
Empty string if an instance identifier has not been provided.
variantId
stringrequiredOnline store ID of the product variant to be added.
This is the primary identifier of what is to be added to the cart.
In case of Shopify, this is an integer and does not include the
gid://shopify/ProductVariant/
prefix.In case of online shop systems without a notion of product variants, this is set to the product ID (i.e. is equal to the value of
productId
).quantity
integerrequiredThe quantity of the product to add.