Block Client API
Block Callback FuncAddProductToCart1
Add the given product variant to the current cart.
| Kind | Block Callback |
|---|---|
| Default transport | 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 cases, do not implement this call unless the Bubblehouse team tells you to.
Input
-
instancestring requiredBlock instance identifier passed to the Blocks API.
Empty string if an instance identifier has not been provided.
-
variantIdstring requiredOnline 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). -
quantityinteger requiredThe quantity of the product to add.
-
productIdstring optionalOnline store ID of the product containing the variant.
-
optionsobject or null optionalProduct or variant options needed by the cart action.
-
discountCodestring optionalCoupon code to apply with the product.
-
ignoreIfAlreadyAddedboolean optionalSkip the cart action when the variant is already present.
A skipped action completes without a success message, refresh, or cart navigation.
-
successMessagestring optionalMessage to show after a successful cart action.
-
cartUrlstring or null optionalCart destination to use after success when there is no success message.
-
refreshOnAddboolean optionalReload the rewards view after showing a success message.