decrementInventory( )


Subtracts a set number of items from inventory.

The decrementInventory() function returns a Promise that is resolved when the specified item's quantity has been updated in the inventory.

Method Declaration
Copy
function decrementInventory(items: Array<DecrementInfo>): Promise<void>;
Method Parameters
itemsArray<DecrementInfo>Required

Inventory items to decrement.

Decrement the inventory of a product's first variant
JavaScript
/******************************* * Backend code - inventory.jsw * *******************************/ import wixStoresBackend from "wix-stores-backend"; export function decrementInventory(decrementInfo) { return wixStoresBackend.decrementInventory(decrementInfo); } /************** * Page code * **************/ import { decrementInventory } from "backend/inventory"; async function decrementHandler() { const productId = "3fb6a3c8-988b-8755-04bd-ks75ae0b18ea"; let variants = await getProductVariants(productId); decrementInventory([ { variantId: variants[0]._id, productId: productId, decrementBy: 1, }, ]) .then(() => { console.log("Inventory decremented successfully"); }) .catch((error) => { // Inventory decrement failed console.error(error); }); }
Did this help?

deleteFulfillment( )


Deprecated. This function will continue to work until September 4, 2024, but a newer version is available at wix-ecom-backend.OrderFulfillments.deleteFulfillment().

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.deleteFulfillment().

To migrate to the new function:

  1. Add the new import statement:

    Copy
  2. Look for any code that uses wixStoresBackend.deleteFulfillment(), and replace it with orderFulfillments.deleteFulfillment(). Update your code to work with the new deleteFulfillment() response properties.

  3. Test your changes to make sure your code behaves as expected.

Deletes a fulfillment from an order.

The deleteFulfillment() function returns a Promise that is resolved to an updated Order object when the specified fulfillment is deleted from the order.

Method Declaration
Copy
Method Parameters
orderIdstringRequired

ID of the order to delete the fulfillment from.


fulfillmentIdstringRequired

ID of the fulfillment to delete.

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

deleteProduct( )


Deletes an existing product.

The deleteProduct() function returns a Promise that resolves when the product with the given ID is deleted.

Method Declaration
Copy
Method Parameters
productIdstringRequired

ID of the product to delete.

Delete a product by ID
JavaScript
Did this help?

deleteProductOptions( )


Deletes all options for an existing product.

The deleteProductOptions() function returns a Promise that resolves when the options for the product with the given ID are deleted.

Method Declaration
Copy
Method Parameters
productIdstringRequired

ID of the product with options to delete.

Delete the options for a product
JavaScript
Did this help?

getCurrentCart( )


Deprecated. This function will continue to work until September 4, 2024, but a newer version is available at wix-ecom-backend.CurrentCart.getCurrentCart().

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.CurrentCart.getCurrentCart().

To migrate to the new function:

  1. Add the new import statement:

    Copy
  2. Look for any code that uses wixStoresBackend.getCurrentCart(), and replace it with currentCart.getCurrentCart(). Update your code to work with the new getCurrentCart() response properties. For more info about the differences between the Stores Cart and eCommerce Cart, refer to the cart conversion table.

  3. Test your changes to make sure your code behaves as expected.

Gets the current site visitor's shopping cart.

The getCurrentCart() function returns a Promise that resolves to the current site visitor's shopping cart.

Note: When editing a site as a collaborator, getCurrentCart() will only work when viewing the live site.

Method Declaration
Copy
Request
This method does not take any parameters
Returns
Return Type:Promise<Cart>
Get the current site visitor's cart

This example uses a deprecated function.

JavaScript
Did this help?



getProductOptionsAvailability( )


Gets the availability of a product based on the specified option choices.

The getProductOptionsAvailability() function returns a Promise that is resolved to a ProductOptionsAvailability object when the product's availability information is retrieved.

The information returned in the selectedVariant and availableForPurchase properties reflects the option choices passed in using the ProductChoices parameter.

If the specified choices result in the selection of a single product variant, that variant is returned in the selectedVariant property and the availableForPurchase property indicates whether that product variant is available for purchase.

If the specified choices do not result in the selection of a single product variant, no variant is returned in the selectedVariant property and the availableForPurchase property will be false.

Method Declaration
Copy
Method Parameters
productIdstringRequired

The ID of the product whose availability is being checked.


choicesProductChoicesRequired

Option choices to use when checking the product's availability.

Returns
Return Type:Promise<ProductOptionsAvailability>

This example gets a product's availability information using an option choice. The product contains more than one option, so no variant is selected and the product with the specified choices is not available for purchase.

JavaScript
Did this help?

getProductVariants( )


Gets a product's available variants based on the specified product ID and either option choices or variant IDs.

The getProductVariants() function returns a Promise that is resolved to an array of VariantItem objects when the product variants with the specified choices or variant IDs are retrieved.

Method Declaration
Copy
Method Parameters
productIdstringRequired

The ID of the product whose variants are being retrieved. Pass only this field to retrieve all the specified product's variants.


optionsProductVariantOptions

Variant options to return. If not specified, all the product's variants are returned.

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

incrementInventory( )


Adds a set number of items from inventory.

The incrementInventory() function returns a Promise that is resolved when the specified item's quantity has been updated in the inventory.

Method Declaration
Copy
Method Parameters
itemsArray<IncrementInfo>Required

Inventory items to increment.

Increment the inventory of a product's first variant
JavaScript
Did this help?

removeProductMedia( )


Removes media items by ID from a product.

The removeProductMedia() function returns a Promise that resolves when the media items with the given IDs are removed from a product with a given ID. You can remove multiple media items from a product at one time by delimiting the list of products with commas.

If you do not specify any media IDs, all media items are removed from the product.

Removing media items from a product does not delete the media from the site.

Method Declaration
Copy
Method Parameters
productIdstringRequired

ID of the product from which to remove media items.


mediaArray<Media>Required

Sources of media items already uploaded to the Wix site. If no media is specified, all media items are removed from the product.

Remove all media items from a product
JavaScript
Did this help?

removeProductMediaFromChoices( )


Removes media items by ID from a product's options.

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.

Method Declaration
Copy
Method Parameters
productIdstringRequired

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


mediaChoicesArray<MediaChoice>Required

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.

Remove media items from product choices
JavaScript
Did this help?