removeProductsFromCollection( )


Removes products by ID from a collection.

The removeProductsFromCollection() function returns a Promise that resolves when the products with the given IDs are removed from a specified collection.

You can remove multiple products from a collection at one time by delimiting the list of products with commas.

If you do not specify any IDs, all products are removed from the collection.

Removing products from a collection does not delete the products from the store. See deleteProduct() to delete a product from the store.

Method Declaration
Copy
function removeProductsFromCollection(
  collectionId: string,
  productIds: Array<string>,
): Promise<void>;
Method Parameters
collectionIdstringRequired

ID of the collection from which to remove products.


productIdsArray<string>Required

IDs of the products to remove from the collection.

Remove products from a product collection
JavaScript
/******************************* * Backend code - products.jsw * *******************************/ import wixStoresBackend from 'wix-stores-backend'; export function removeProductsFromCollection(collectionId, productIds) { return wixStoresBackend.removeProductsFromCollection(collectionId, productIds); } /************* * Page code * *************/ import { removeProductsFromCollection } from 'backend/products'; // ... const collectionId = ... // get collection ID const productIds = ["id1", "id2", "id3"]; removeProductsFromCollection(collectionId, productIds) .then(() => { // products removed from the collection }) .catch((error) => { // products not removed from the collection });
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?