Interface: Actions
Provides methods for manipulating the configurator state and controlling product configurations.
The Actions interface gives you direct control over the product configurator, allowing you to programmatically change options, control the camera, manage the scene, export content, and perform various operations that would normally require user interaction.
Example
// Select a product option
const option = { /* option data */ };
window.mimeeqApp.actions.markOption(option, 'block123', 'colorPicker');
// Zoom out to see the entire product
window.mimeeqApp.actions.zoomOut();
AugmentedReality
generateAR
generateAR:
GenerateAR
Function
Creates an Augmented Reality (AR) version of the current product configuration.
This action processes the current product with all its customizations and generates an AR-ready model that can be viewed on compatible devices. It returns a unique shortcode that can be used to access the AR experience.
Business value:
- Allows customers to visualize products in their actual environment before purchase
- Reduces returns by setting accurate expectations of product size and appearance
- Creates engaging marketing experiences that drive conversion
- Provides sales teams with powerful visualization tools for client meetings
Dispatches mimeeq-generate-ar-short-code
-
- with the AR short code when the model is ready.
Example
// Add a "View in your space" AR button to your product page
document.getElementById('view-in-ar').addEventListener('click', () => {
window.mimeeqApp.actions.generateAR().then(shortcode => {
if (shortcode) {
window.location.href = `/ar-viewer?code=${shortcode}`;
}
});
});
getARShortCodeData
getARShortCodeData:
GetARShortCodeData
Function
Retrieves detailed information about an AR model from its shortcode.
This action looks up an existing AR model using its unique identifier and returns comprehensive information about the model, including file paths, product details, and conversion status. For models still being processed, it can provide a subscription to notify when processing completes.
Business value:
- Supports seamless AR experiences by accessing previously created AR models
- Enables informative loading states when AR models are still processing
- Provides product details for consistent AR experience labeling
- Allows tracking of AR model status for analytics and troubleshooting
Example
// Load AR viewer with proper model information
const arShortcode = getParameterFromUrl('code');
if (arShortcode) {
window.mimeeqApp.actions.getARShortCodeData(arShortcode, true)
.then(arData => {
if (arData) {
if (arData.glbPath && arData.usdzPath) {
// Models are ready, load AR viewer
initializeARViewer(arData);
} else if (arData.completeSubscription) {
// Models are processing, wait for completion
showLoadingIndicator();
arData.completeSubscription.then(result => {
hideLoadingIndicator();
initializeARViewer({...arData, ...result});
});
}
} else {
showErrorMessage("AR model not found");
}
});
}
Param
Unique identifier for the AR model
Param
Whether to include a completion notification for processing models
regenerateAR
regenerateAR:
RegenerateAR
Function
Attempts to recreate an AR model when initial generation fails.
This action tries again to create an AR-compatible version of a product when the first attempt was unsuccessful. It uses existing AR data to ensure consistency and returns a shortcode for accessing the AR experience if successful.
Business value:
- Improves AR reliability by providing automatic recovery from generation failures
- Enhances customer experience by reducing error messages during AR experiences
- Maximizes AR availability for products with complex configurations
- Supports continuous operation of AR features in busy retail environments
Example
// Implement automatic retry when AR generation fails
window.mimeeqApp.actions.generateAR().then(shortcode => {
if (!shortcode && arData) {
// First attempt failed, try again
return window.mimeeqApp.actions.regenerateAR(arData);
}
return shortcode;
}).then(finalShortcode => {
if (finalShortcode) {
window.location.href = `/ar-viewer?code=${finalShortcode}`;
} else {
showErrorMessage("AR currently unavailable for this product");
}
});
Param
Previously generated AR data containing model information
showAR
showAR:
ShowAR
Function
Opens the Augmented Reality (AR) viewing interface.
This method initiates the AR experience for the current product configuration. On desktop devices, it displays a modal with a QR code that mobile users can scan to view the product in AR. On mobile devices, it directly launches the AR viewer.
AR viewing allows customers to visualize products in their actual physical space, providing a powerful tool for evaluating size, fit, and appearance in context.
Example
// Add a custom AR button to your interface
document.getElementById('custom-ar-btn').addEventListener('click', () => {
window.mimeeqApp.actions.showAR();
});
Authentication
havePermissions
havePermissions:
HavePermissions
Function
Checks if the current user has specific permissions.
This method verifies whether the logged-in user has any of the specified permissions, which control access to various features and actions in the system. It's useful for conditionally showing or enabling functionality based on user permissions.
Permission-based UI adaptation ensures users only see and access features they're authorized to use, providing a cleaner and more secure experience.
Example
// Only show the export button if the user has export permissions
window.mimeeqApp.actions.havePermissions(['EXPORT_OBJ', 'EXPORT_STL'])
.then(canExport => {
document.getElementById('export-button').style.display =
canExport ? 'block' : 'none';
});
Param
Array of permission identifiers to check
Basket
prepareCartImage
prepareCartImage:
PrepareCartImage
Function
Prepares an image for inclusion in a cart item.
This method uploads a product image (provided as a base64 string) to storage and returns a reference path that can be used when adding items to the cart. The image serves as a visual representation of the specific configuration being ordered.
Cart images improve the shopping experience by providing visual confirmation of selected products in the cart, order confirmation emails, and order history.
Example
// Create an image of the current configuration for a cart item
window.mimeeqApp.utils.takeScreenshot('jpg', 800)
.then(async (imageBase64) => {
const imagePath = await window.mimeeqApp.actions.prepareCartImage(
imageBase64,
'cart_123',
'item_456'
);
// Add the item to cart with the prepared image
addToCartWithImage(imagePath);
});
Param
Base64-encoded image data
Param
ID of the cart the image will be associated with
Param
ID of the specific cart item the image represents
Basket Operations
addItemToCart
addItemToCart:
AddItemToCart
Function
Adds an item to the shopping cart.
This method allows you to programmatically add a configured product to the cart, including all its selected options, pricing information, and quantity. It's the digital equivalent of placing a physical product in a shopping basket, ensuring all the customizations and pricing details are accurately captured.
Business value:
- Enables seamless e-commerce integration with your configurator
- Allows for one-click add-to-cart functionality from custom interfaces
- Supports automated ordering processes or bulk-add operations
- Maintains all configuration details for manufacturing or fulfillment
Example
// Add a configured desk to the cart
const cartItem = {
productId: 'prod_desk_123',
productName: 'Executive Desk',
variantCode: 'Width-a9&Material-b5&Color-c3',
quantity: 2,
companyId: 'company_456',
priceType: 'SALE',
sku: 'DESK-EX-001',
isModular: false,
// other required properties...
};
await window.mimeeqApp.actions.addItemToCart(cartItem);
console.log('Product added to cart successfully');
Param
Complete definition of the item to add, including product details, pricing context, and quantity
Throws
Will throw an error if the item cannot be added or if required information is missing
createCart
createCart:
CreateCart
Function
Creates a new empty shopping cart.
This method initializes a new cart in the system, generating a unique identifier that can be used for subsequent cart operations. Creating a new cart is typically the first step in a shopping journey for a new session or after a previous cart has been completed or abandoned.
The created cart will be associated with the current user if they are authenticated, or tracked via session for guest users. Multiple carts can exist simultaneously, allowing for scenarios like saved carts, wish lists, or quote comparisons.
Example
// Create a new empty cart at the beginning of a shopping session
const { cartId } = await window.mimeeqApp.actions.createCart();
console.log(`New cart created with ID: ${cartId}`);
// Store the cart ID for future operations
sessionStorage.setItem('currentCartId', cartId);
getCartForPreview
getCartForPreview:
GetCartForPreview
Function
Retrieves comprehensive cart data formatted for display or email sharing.
This method fetches complete cart information including all items, pricing details, customer contact information, and submission data. The returned data is structured for presentation in review screens, email previews, or order confirmation displays.
The cart preview includes not only the basic product information but also calculates totals, applies any price modifiers or discounts, and formats custom fields for easy reading.
Example
// Retrieve a cart for preview before submission
const cartPreview = await window.mimeeqApp.actions.getCartForPreview('cart_123456');
// Display cart summary information
document.getElementById('cart-total').textContent =
`${cartPreview.totalValue} ${cartPreview.currency}`;
// Display all items in the cart
const itemsList = document.getElementById('cart-items');
cartPreview.cartItems.forEach(item => {
itemsList.innerHTML += `<li>${item.quantity}x ${item.productName}</li>`;
});
Param
The unique identifier for the cart to retrieve
Throws
Will throw an error if the cart cannot be found or if access is denied
getCartItems
getCartItems:
GetCartItems
Function
Retrieves all items currently in the specified cart.
This method fetches the full list of products that have been added to a cart, including their quantities, configurations, and current prices. It's essential for displaying cart contents, calculating totals, or implementing cart management interfaces.
The response includes complete item details that can be used to render cart items, allow quantity adjustments, show product thumbnails, and display price information.
If the cart is not accessible (e.g., closed, doesn't exist, or forbidden), the method returns an object with a code indicating the specific issue rather than throwing an error.
Example
// Fetch and display all items in the current cart
const cartItems = await window.mimeeqApp.actions.getCartItems('cart_123456');
// Check if we received an error code
if ('code' in cartItems) {
if (cartItems.code === 'CART_CLOSED') {
showMessage('This cart has already been submitted');
} else if (cartItems.code === 'CART_NOT_FOUND') {
showMessage('Cart not found - please create a new one');
}
return;
}
// Display the cart items
cartItems.forEach(item => {
addItemToCartDisplay(item);
});
Param
The unique identifier for the cart to retrieve items from
getCartSubmissionForm
getCartSubmissionForm:
GetCartSubmissionFormAction
Function
Retrieves the custom fields and form structure required for cart submission.
This method fetches the collection of form fields needed to complete a cart submission, including both standard fields (name, email, etc.) and any custom fields defined for the cart submission process. The returned fields contain all necessary validation rules, display properties, and ordering information.
The form structure is typically used to build a dynamic checkout form that collects the required customer information before finalizing an order. Field types can include text inputs, dropdowns, checkboxes, and more complex components like rich text areas.
Example
// Fetch the submission form structure and build a dynamic form
const formFields = await window.mimeeqApp.actions.getCartSubmissionForm('cart_123456');
// Sort fields by their ordinal position
formFields.sort((a, b) => a.ordinal - b.ordinal);
// Create form elements for each field
const formContainer = document.getElementById('checkout-form');
formFields.forEach(field => {
const formControl = createFormControl(field);
formContainer.appendChild(formControl);
});
Param
The unique identifier for the cart
Throws
Will throw an error if the cart ID is missing or if form retrieval fails
preSubmitCart
preSubmitCart:
PreSubmitCart
Function
Saves partial contact information without fully submitting the cart.
This method allows for incrementally saving customer information during the checkout process without finalizing the order. It's useful for multi-step checkout flows, saving checkout progress, or preparing a cart for later submission.
When contact information is pre-submitted, it's associated with the cart but doesn't trigger the final submission workflow. This allows for scenarios like saving contact details while continuing to shop, validating information before final submission, or creating a draft order to be finalized later.
The method also returns updated price modifiers which may have changed based on the submitted information (e.g., discount eligibility based on company or region).
Example
// Save contact information from the first checkout step
const contactInfo = {
fullName: 'Jane Smith',
email: '[email protected]',
companyName: 'Acme Corp',
language: 'en',
// Partial data - more fields will be added in subsequent steps
};
const result = await window.mimeeqApp.actions.preSubmitCart('cart_123456', contactInfo);
// Check if any price modifiers were applied based on the contact info
if (result.priceModifiers.length > 0) {
updatePricingDisplay(result.priceModifiers);
}
Param
The unique identifier for the cart
Param
Partial contact and submission information to save
Throws
Will throw an error if the cart ID is missing or if pre-submission fails
recalculateCart
recalculateCart:
RecalculateCart
Function
Recalculates all prices in the cart based on specified pricing parameters.
This method updates all item prices in the cart according to the provided pricing context, which can include company-specific pricing, price types (cost, retail, sale), price list groups, and template-specific pricing rules. It's essential for ensuring accurate pricing when the pricing context changes during the shopping process.
Common scenarios for recalculation include:
- When a salesperson switches the company they're ordering on behalf of
- When changing between price types (e.g., from retail to wholesale pricing)
- When specific discount programs or price lists are applied
- When the embedded template context changes, affecting pricing rules
The method returns updated cart items with recalculated prices and any applicable price modifiers (discounts, surcharges, etc.).
Dispatches mimeeq-basket-updated
-
- with the recalculated cart state once prices are updated.
Example
// Recalculate cart prices when switching to wholesale pricing for a dealer
const updatedCart = await window.mimeeqApp.actions.recalculateCart(
'cart_123456', // Cart ID
'company_dealer_789', // Dealer company ID
'WHOLESALE', // Price type
'dealer_program_A' // Price list group
);
// Update the UI with new pricing
updateCartDisplay(updatedCart.cartItems);
// Show any applied discounts or surcharges
if (updatedCart.priceModifiers.length > 0) {
showPriceModifiers(updatedCart.priceModifiers);
}
Param
The unique identifier for the cart to recalculate
Param
Optional company ID to use for company-specific pricing
Param
Optional price type to use (e.g., 'COST', 'RRP', 'SALE')
Param
Optional price list group to apply for special pricing programs
Param
Optional ID of the embed template context
Throws
Will throw an error if recalculation fails or the cart is inaccessible
removeCartItem
removeCartItem:
RemoveCartItem
Function
Removes a specific item from the cart.
This method deletes a single item from the cart based on its unique identifier. It's equivalent to taking a product out of your shopping basket before checkout, and provides immediate feedback to reflect the updated cart state.
Business value:
- Gives customers control to refine their selections before purchase
- Immediately updates pricing totals to reflect removed items
- Supports dynamic cart management in custom interfaces
- Helps prevent order errors by allowing easy removal of unwanted items
Example
// Remove an item when the user clicks a "Remove" button
document.querySelector('.remove-item-btn').addEventListener('click', async (e) => {
const cartId = e.target.dataset.cartId;
const itemId = e.target.dataset.itemId;
try {
await window.mimeeqApp.actions.removeCartItem(cartId, itemId);
// Remove the item from the UI
document.getElementById(`cart-item-${itemId}`).remove();
// Update cart totals
updateCartTotals();
} catch (error) {
showErrorMessage('Could not remove item from cart');
}
});
Param
The unique identifier for the cart
Param
The unique identifier for the specific item to remove
Throws
Will throw an error if the cart or item ID is missing or if removal fails
submitCart
submitCart:
SubmitCart
Function
Finalizes and submits a cart for processing.
This method completes the checkout process by submitting the cart with all required customer information. It transforms the cart into an order that can be processed through subsequent fulfillment workflows. Once submitted, the cart is typically locked and cannot be modified further.
The submission process:
- Validates all required fields are present and properly formatted
- Finalizes pricing calculations and applies any last-minute price modifiers
- Generates a unique reference code for tracking the submitted order
- Changes the cart status to prevent further modifications
- Triggers any configured notifications (e.g., email confirmations)
This is typically the final step in the purchasing process within the configurator.
Example
// Submit a cart with complete customer information
const customerInfo = {
fullName: 'John Doe',
email: '[email protected]',
phone: '+1 555-123-4567',
companyName: 'Acme Corporation',
address: '123 Main St, Anytown, USA',
language: 'en',
submittedAt: Date.now(),
notes: 'Please deliver to loading dock B',
// Any custom fields collected during checkout
customFields: {
deliveryPreference: 'morning',
specialInstructions: true
},
parameters: [] // Processed custom fields
};
const result = await window.mimeeqApp.actions.submitCart('cart_123456', customerInfo);
// Show confirmation with reference code
showOrderConfirmation(result.referenceCode);
Param
The unique identifier for the cart to submit
Param
Complete customer information and submission details
Throws
Will throw an error if submission fails due to missing information or system issues
CameraControl
decreaseZoom
decreaseZoom:
DecreaseZoom
Function
Decreases the camera zoom level to see more of the product and its surroundings.
This action moves the camera farther away from the product, giving viewers a broader perspective. It's ideal for showcasing the product's overall proportions, viewing larger furniture arrangements, or seeing how multiple components fit together.
Business value:
- Helps customers understand the overall size and scale of products
- Shows how products fit within an environment or alongside other pieces
- Provides context for furniture arrangements or room layouts