removeProductMediaFromChoices( )


Removes media items by ID from a product's options.

The removeProductMediaFromChoices() function returns a Promise that resolves when the products with the given IDs are removed from a product's options.

You can remove multiple media items from a product's option at one time by delimiting the list of options with commas.

Removing media items from a product option does not delete the media items from the product.

Method Declaration
Copy
function removeProductMediaFromChoices(
  productId: string,
  mediaChoices: Array<MediaChoice>,
): Promise<void>;
Method Parameters
productIdstringRequired

ID of the product from whose options to remove media items.


mediaChoicesArray<MediaChoice>Required

Media items already uploaded to the Wix site, and the choices to which to upload the media. If no choices are specified, the media items are removed from all choices for the given product.

Remove media items from product choices
JavaScript
/******************************* * Backend code - products.jsw * *******************************/ import wixStoresBackend from "wix-stores-backend"; export function removeProductMediaFromChoices(productId, choiceIds) { return wixStoresBackend.removeProductMediaFromChoices(productId, choiceIds); } /************* * Page code * *************/ import { removeProductMediaFromChoices } from "backend/products"; // ... const productId = "1a11aaa3-...-111a1aaa111"; const choices = [ { option: "Color", choice: "Blue", }, ]; removeProductMediaFromChoices(productId, choices) .then(() => { // media items removed from the product choices }) .catch((error) => { // media items not removed from the product choices });
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?