Last updated

updateCartItemVariant()

Updates the variant of an existing cart item.

Signature

await window.FairShareSDK.updateCartItemVariant({ itemId, variantId });

Parameters

ParameterTypeDescription
optionsobjectOptions object

Options:

PropertyTypeDescription
itemIdnumberThe cart item ID to update
variantIdnumberThe new variant ID

Example

// Change item to a different variant (e.g., different size or color)
await window.FairShareSDK.updateCartItemVariant({
  itemId: 123,
  variantId: 456
});

Use Case

This is useful when a customer wants to change a product option (like size or color) without removing and re-adding the item:

// Customer selected a different size
const newVariantId = 789;
const cartItemId = 123;

await window.FairShareSDK.updateCartItemVariant({
  itemId: cartItemId,
  variantId: newVariantId
});