Basics: Wishlist
Introduction
This section will cover the basics of the wishlist and how to use it. We will also cover how to add, remove and clear products from the wishlist.
API Reference
You can find all available BigCommerce module methods and their description in the API Reference.
Creating a wishlist
To create a new wishlist, you can use the createWishlist method.
The customer must be authenticated and the customer's id
will be picked up automatically from the requests header.
import { sdk } from '~/sdk.config.ts';
const createWishlistResponse = await sdk.bigcommerce.createWishlist({
{
"name": "My very own Wishlist!",
"is_public": true,
"items": []
}
});
Fetching all customer wishlists
To fetch the wishlists, you can use the getAllWishlist method.
To fetch all wishlist, you can pass the wishlist's id as the id
parameter. This will return a collection of wishlists. In case where a single wishlist should be returned, the resposne of this call can be filtered to find the match.
The customer must be authenticated and the customer's id
will be picked up automatically from the requests header.
import { sdk } from '~/sdk.config.ts';
const getAllWishlistsResponse = await sdk.bigcommerce.getAllWishlists();
Deleting a wishlist
To delete a wishlist, you can use the deleteWishlist method passing the wishlists id
.
The customer must be authenticated and the customer's id
will be picked up automatically from the requests header.
import { sdk } from '~/sdk.config.ts';
const deleteWishlistResponse = await sdk.bigcommerce.deleteWishlist({
wishlistId: 30
});
Add items to the wishlist
You can use the addWishlistItem method to add the items to the wishlist by specifiying the id
of the product and the quantity
.
import { sdk } from '~/sdk.config.ts';
const addWishlistItem = await sdk.bigcommerce.addWishlistItem({
wishlistId: '7c3ab631-782c-4747-8ccc-873e87de5152',
items: [{
product_id: 112,
}]
})
When adding a product with variants, a variant_id
should be passed together with the item
const addWishlistItem = await sdk.bigcommerce.addWishlistItem({
wishlistId: '7c3ab631-782c-4747-8ccc-873e87de5152',
items: [{
product_id: 112,
variant_id: 94
}]
})
Remove Wishlist Item
You can use the removeWishlistItem method to remove the item from the wishlist by specifiying the id
of the wishlist and the wishlist item id
.
import { sdk } from '~/sdk.config.ts';
const removeWishlistItemResponse = await sdk.bigcommerce.removeWishlistItem({
wishlistId: '7c3ab631-782c-4747-8ccc-873e87de5152',
itemId: 132
}
})