Search...
addProductMediaToChoices( )
Adds media items by ID to product options.
Description
The addProductMediaToChoices()
function returns a Promise that resolves when the adding of
media (images or videos) to a product's options has started.
Authorization
Request
This endpoint does not take any parameters
Response Object
Fulfilled - When the media items are added to the product options. Rejected - Error message.
Returns an empty object.
Status/Error Codes
Related Content:
Was this helpful?
Add media items to product options
Copy Code
1/*******************************2 * Backend code - products.jsw *3 *******************************/45import wixStoresBackend from 'wix-stores-backend';67export function addProductMediaToChoices(productId, mediaData) {8 return wixStoresBackend.addProductMediaToChoices(productId, mediaData);9}1011/*************12 * Page code *13 *************/1415import { addProductMediaToChoices } from 'backend/products';1617// ...1819const productId = ...; // get product ID20const mediaSources = ["wix:image://v1/1a11a1_..._1a~mv2.jpg/1a11a1_..._1a~mv2.jpg"];21const option = "Color";22const choice = "Blue";2324const mediaData = [{25 mediaSources,26 option,27 choice28}];2930addProductMediaToChoices(productId, mediaData)