removeProductMediaFromChoices( )
Removes media items by ID from a product's options.
Description
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.
Syntax
function removeProductMediaFromChoices(productId: string, mediaChoices: Array<MediaChoice>): Promise<void>
removeProductMediaFromChoices Parameters
NAME
TYPE
DESCRIPTION
ID of the product from whose options to remove media items.
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.
Returns
Fulfilled - When the media items are removed from the product options. Rejected - Error message.
Return Type:
Related Content:
Was this helpful?
Remove media items from product choices
1/*******************************2 * Backend code - products.jsw *3 *******************************/45import wixStoresBackend from 'wix-stores-backend';67export function removeProductMediaFromChoices(productId, choiceIds) {8 return wixStoresBackend.removeProductMediaFromChoices(productId, choiceIds);9}1011/*************12 * Page code *13 *************/14import { removeProductMediaFromChoices } from 'backend/products';1516// ...1718const productId = "1a11aaa3-...-111a1aaa111";19const choices = [{20 "option": "Color",21 "choice": "Blue"22}]2324removeProductMediaFromChoices(productId, choices)25 .then(() => {26 // media items removed from the product choices27 })28 .catch(error => {29 // media items not removed from the product choices30 })