addProductMediaToChoices( )


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.

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

ID of the product with choices to which to add media items.


mediaChoicesArray<MediaChoice>Required

Product media items, and the choices to add the media to.

Note: Media must already be added to the product.

Add media items to product options
JavaScript
/******************************* * 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)
Did this help?

addProductsToCollection( )


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.

Method Declaration
Copy
Method Parameters
collectionIdstringRequired

ID of the product collection to which to add products.


productIdsArray<string>Required

IDs of the products to add to the product collection, separated by commas.

Add products to a product collection
JavaScript
Did this help?

bulkAdjustProductProperty( )


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.

Method Declaration
Copy
Method Parameters
idsArray<string>Required

IDs of the products to adjust.


adjustBulkAdjustPropertiesRequired

Numeric property to adjust.

Returns
Return Type:Promise<BulkUpdateResponse>
JavaScript
Did this help?

bulkUpdateProductProperty( )


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.

Method Declaration
Copy
Method Parameters
idsArray<string>Required

IDs of the products to update.


setBulkUpdatePropertiesRequired

Property to update.

Returns
Return Type:Promise<BulkUpdateResponse>
JavaScript
Did this help?

createFulfillment( )


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.

Migration Instructions

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:

  1. Add the new import statement:

    Copy
  2. 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.

  3. 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.

Method Declaration
Copy
Method Parameters
orderIdstringRequired

ID of the order to create the fulfillment in.


fulfillmentFulfillmentInfoRequired

Fulfillment information.

Returns
Return Type:Promise<NewFulfillmentAndOrder>
Create a new fulfillment
JavaScript
Did this help?

createOrder( )


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.

Migration Instructions

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:

  1. Add the new import statement:

    Copy
  2. 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.

  3. 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.

Method Declaration
Copy
Method Parameters
orderInfoOrderInfoRequired

The information for the order being created.

Returns
Return Type:Promise<Order>
JavaScript
Did this help?

createProduct( )


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:

  • If you create a product immediately before adding it to the cart, we suggest setting a timeout for "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.
  • 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.
Method Declaration
Copy
Method Parameters
productInfoProductInfoRequired

Information for the product being created.

Returns
Return Type:Promise<Product>
JavaScript
Did this help?