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.
function decrementInventory(items: Array<DecrementInfo>): Promise<void>;
Inventory items to decrement.
/*******************************
* 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);
});
}
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.
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:
Add the new import statement:
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.
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.
ID of the order to delete the fulfillment from.
ID of the fulfillment to delete.
Deletes an existing product.
The deleteProduct()
function returns a Promise that resolves when the
product with the given ID is deleted.
ID of the product to delete.
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.
ID of the product with options to delete.
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.
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:
Add the new import statement:
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.
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.
This example uses a deprecated function.
Generates a link to a PDF file containing information about one or more specified orders, up to 1000 orders.
The getOrdersLink()
function returns a Promise that resolves to an object containing the URL of a PDF file with the specified orders' information, 1 order per page.
IDs of the orders for which to generate a PDF file.
Generates a link to a PDF file containing an order's packing slip.
The getPackingSlipLink()
function returns a Promise that resolves to an object containing the URL of a PDF file with the specified order's packing slip.
ID of the order for which to generate a packing slip.
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
.
The ID of the product whose availability is being checked.
Option choices to use when checking the product's availability.
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.
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.
The ID of the product whose variants are being retrieved. Pass only this field to retrieve all the specified product's variants.
Variant options to return. If not specified, all the product's variants are returned.
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.
Inventory items to increment.
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.
ID of the product from which to remove media items.
Sources of media items already uploaded to the Wix site. If no media
is specified, all media items are removed from the product.
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.
ID of the product from whose options to remove media items.
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.