Type Alias: AddToCart()
AddToCart = (
skipSceneValidation?) =>Promise<null|false|undefined>
Triggers the "add to cart" or "finish" action for the current configuration.
This method programmatically executes the same action that occurs when a user clicks the "Add to Cart" or "Finish" button in the configurator. It prepares all the necessary configuration details and dispatches the appropriate events.
Parameters
skipSceneValidation?
boolean
Returns
Promise<null | false | undefined>
A promise that resolves to false when the configured scene-validation
policy blocks the action, or to null when required preconditions are missing
(e.g. no main product, missing product/customer identifiers, or no scene short
code). Successful actions resolve with undefined after the corresponding event
has been dispatched.
Example
// Add the current configuration to the cart when a custom button is clicked
document.getElementById('custom-add-to-cart').addEventListener('click', () => {
window.mimeeqApp.utils.addToCart();
});
// Listen for the add to cart event to handle the data
document.addEventListener('mimeeq-add-to-cart', (e) => {
console.log('Product added to cart:', e.detail);
// Add the product to your e-commerce system
});
// Intercept the action before validation and payload preparation
document.addEventListener('mimeeq-before-add-to-cart', (e) => {
e.preventDefault();
e.detail.continueAddToCart();
});
Fires
@mimeeq/mimeeq-before-add-to-cart
Fires
@mimeeq/mimeeq-add-to-cart