Search...
removeProductsFromCollection( )
Removes products by ID from a collection.
Description
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.
Syntax
function removeProductsFromCollection(collectionId: string, productIds: Array<string>): Promise<void>
removeProductsFromCollection Parameters
NAME
TYPE
DESCRIPTION
collectionId
string
ID of the collection from which to remove products.
productIds
Array<string>
IDs of the products to remove from the collection.
Returns
Fulfilled - When the products are removed from the collection. Rejected - Error message.
Return Type:
Promise<void>
Was this helpful?
Remove products from a product collection
Copy Code
1/*******************************2 * Backend code - products.jsw *3 *******************************/45import wixStoresBackend from 'wix-stores-backend';67export function removeProductsFromCollection(collectionId, productIds) {8 return wixStoresBackend.removeProductsFromCollection(collectionId, productIds);9}1011/*************12 * Page code *13 *************/1415import { removeProductsFromCollection } from 'backend/products';1617// ...1819const collectionId = ... // get collection ID20const productIds = ["id1", "id2", "id3"];2122removeProductsFromCollection(collectionId, productIds)23 .then(() => {24 // products removed from the collection25 })26 .catch((error) => {27 // products not removed from the collection28 });