Search.../

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
productId
string

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

mediaChoices
Array<MediaChoice>

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:

Promise<void>

Related Content:

Was this helpful?

Remove media items from product choices

Copy Code
1/*******************************
2 * Backend code - products.jsw *
3 *******************************/
4
5import wixStoresBackend from 'wix-stores-backend';
6
7export function removeProductMediaFromChoices(productId, choiceIds) {
8 return wixStoresBackend.removeProductMediaFromChoices(productId, choiceIds);
9}
10
11/*************
12 * Page code *
13 *************/
14import { removeProductMediaFromChoices } from 'backend/products';
15
16// ...
17
18const productId = "1a11aaa3-...-111a1aaa111";
19const choices = [{
20 "option": "Color",
21 "choice": "Blue"
22}]
23
24removeProductMediaFromChoices(productId, choices)
25 .then(() => {
26 // media items removed from the product choices
27 })
28 .catch(error => {
29 // media items not removed from the product choices
30 })