Adds media items by ID to product options.
The addProductMediaToChoices()
function returns a Promise that resolves when the adding of
media (images or videos) to a product's options has started.
function addProductMediaToChoices(
productId: string,
mediaChoices: Array<MediaChoice>,
): Promise<void>;
ID of the product with choices to which to add media items.
Product media items, and the choices to add the media to.
Note: Media must already be added to the product.
/*******************************
* Backend code - products.jsw *
*******************************/
import wixStoresBackend from 'wix-stores-backend';
export function addProductMediaToChoices(productId, mediaData) {
return wixStoresBackend.addProductMediaToChoices(productId, mediaData);
}
/*************
* Page code *
*************/
import { addProductMediaToChoices } from 'backend/products';
// ...
const productId = ...; // get product ID
const mediaSources = ["wix:image://v1/1a11a1_..._1a~mv2.jpg/1a11a1_..._1a~mv2.jpg"];
const option = "Color";
const choice = "Blue";
const mediaData = [{
mediaSources,
option,
choice
}];
addProductMediaToChoices(productId, mediaData)
Adds products by ID to a product collection.
The addProductsToCollection()
function returns a Promise that resolves when the
products with the given IDs are added to a product collection with a given ID.
You can add multiple products to a collection at one time by delimiting the list of products with commas.
With this function, you can only add existing products to a collection. You cannot use the addProductsToCollection()
function to create a product. See createProduct()
to add a product to the store.
ID of the product collection to which to add products.
IDs of the products to add to the product collection, separated by commas.
Adjusts a numeric property for up to 100 products at a time.
The bulkAdjustProductProperty()
function returns a Promise that resolves when the
property of the products have been adjusted.
A property can be increased or decreased either by percentage or amount.
The properties that can be bulk-adjusted are detailed in the adjust
object in the parameters section below.
Note: Do not pass important information from client-side code. Doing so opens a vulnerability that a malicious user can exploit to change information, such as a buyer’s personal details (address, email, etc.) or product price information. To learn more about how to keep your code secure, see Security Considerations When Working with Wix Code.
IDs of the products to adjust.
Numeric property to adjust.
Updates a property for up to 100 products at a time.
The bulkUpdateProductProperty()
function returns a Promise that resolves when the
property of the products have been updated.
The properties that can be bulk-updated are detailed in the set
object in the parameters section below.
Note: Do not pass important information from client-side code. Doing so opens a vulnerability that a malicious user can exploit to change information, such as a buyer’s personal details (address, email, etc.) or product price information. To learn more about how to keep your code secure, see Security Considerations When Working with Wix Code.
IDs of the products to update.
Property to update.
Deprecated.
This function will continue to work until September 4, 2024, but a newer version is available at
wix-ecom-backend.OrderFulfillments.createFulfillment()
.
We recommend you migrate to the new Wix eCommerce APIs as soon as possible.
If this function is already in your code, it will continue to work.
To stay compatible with future changes, migrate to
wix-ecom-backend.OrderFulfillments.createFulfillment()
.
To migrate to the new function:
Add the new import statement:
Look for any code that uses wixStoresBackend.createFulfillment()
,
and replace it with orderFulfillments.createFulfillment()
.
Update your code to work with the new createFulfillment()
response properties.
Test your changes to make sure your code behaves as expected.
Creates a new fulfillment in an order.
The createFulfillment()
function returns a Promise that is resolved
to an object with the fulfillmentId
and the updated Order
when the fulfillment is created.
ID of the order to create the fulfillment in.
Fulfillment information.
Deprecated.
This function will continue to work until September 4, 2024, but a newer version is available at
wix-ecom-backend.Orders.createOrder()
.
We recommend you migrate to the new Wix eCommerce APIs as soon as possible.
If this function is already in your code, it will continue to work.
To stay compatible with future changes, migrate to
wix-ecom-backend.Orders.createOrder()
.
To migrate to the new function:
Add the new import statement:
Look for any code that uses wixStoresBackend.createOrder()
,
and replace it with orders.createOrder()
.
Update your code to work with the new createOrder()
response properties.
Test your changes to make sure your code behaves as expected.
Creates a new order.
The createOrder()
function returns a Promise that resolves to an Order
object when the order has been created.
Note: Do not pass important information from client-side code. Doing so opens a vulnerability that a malicious user can exploit to change information, such as a buyer’s personal details (address, email, etc.) or product price information. To learn more about how to keep your code secure, see Security Considerations When Working with Wix Code.
The information for the order being created.
Creates a new product.
The createProduct()
function receives a ProductInfo
object and returns a Promise that resolves to a Product
object when the product has been created.
Creating a product is the first step in the process of enabling visitors to buy your products. After you create a product, you can add choices and variants to the product.
Notes:
"1000"
milliseconds (1 second) before calling wix-stores.cart.addProducts()
. While this slows down the operation slightly, it also ensures proper retrieval of the newly created product before adding it to the cart.
Information for the product being created.