Skip to main content

Type Alias: RecalculateCart()

RecalculateCart = (cartId, companyId?, priceType?, priceListGroup?, embedTemplateId?) => Promise<RecalculateCartResponse>

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.).

Parameters

cartId

string

The unique identifier for the cart to recalculate

companyId?

string

Optional company ID to use for company-specific pricing

priceType?

string

Optional price type to use (e.g., 'COST', 'RRP', 'SALE')

priceListGroup?

string

Optional price list group to apply for special pricing programs

embedTemplateId?

string

Optional ID of the embed template context

Returns

Promise<RecalculateCartResponse>

A promise that resolves to the recalculated cart with updated prices

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);
}

Throws

Will throw an error if recalculation fails or the cart is inaccessible

Emits

mimeeq-basket-updated When prices have been recalculated, providing updated cart state