Skip to main content

Type Alias: GetRelatedProducts()

GetRelatedProducts = () => Promise<RelatedItem[]>

Function

Retrieves all related products for the current product.

This function fetches a list of products that have been defined as related to the current product. Related products are typically complementary items, accessories, or alternative options that customers might be interested in when viewing the current product.

Related products help increase average order value, improve product discovery, and enhance the shopping experience by suggesting relevant additional items.

Returns

Promise<RelatedItem[]>

A promise resolving to an array of related product items

Example

// Get all related products and display them in a carousel
window.mimeeqApp.actions.getRelatedProducts().then(relatedItems => {
const container = document.getElementById('related-products');

relatedItems.forEach(item => {
const productCard = document.createElement('div');
productCard.className = 'product-card';
productCard.innerHTML = `
<h3>${item.name}</h3>
<button>View Product</button>
`;

productCard.querySelector('button').addEventListener('click', () => {
window.mimeeqApp.actions.selectRelatedProduct(
item.productId,
`${item.code}=${item.defaultConfigurationCode || ''}`,
item.isModular,
item.isActive
);
});

container.appendChild(productCard);
});
});