Published by DJ Steinmetz
October 11th, 2022
To make use of the Product Collections resource, we need:
enterprise-product-id
that is orderable and visible to our buyer user.The first thing we need to do, is create the Product Collection itself. Let's name it "Wishlist" giving it a self-descriptive ID.
POST https://sandboxapi.ordercloud.io/v1/me/productcollections HTTP/1.1
Authorization: Bearer INSERT_ACCESS_TOKEN_HERE
Content-Type: application/json; charset=UTF-8
{
"ID": "wishlist",
"Name": "Wishlist",
}
Adding an entry to our Wishlist Product Collection is as easy as calling PUT /me/productcollections/{productCollectionID}/{productID}
with our Product Collection ID and the product ID we want to add to our collection. If successful, our call should return a 204 No Content
response.
PUT https://sandboxapi.ordercloud.io/v1/me/productcollections/wishlist/enterprise-product-id HTTP/1.1
Authorization: Bearer INSERT_ACCESS_TOKEN_HERE
Content-Type: application/json; charset=UTF-8
Now that we have our Wishlist Product Collection, and have added a product to it, let's list out the products in our Product Collection to see our Wishlist in action. We should see a list page containing one product (enterprise-product-id
) returned from the list call.
GET https://sandboxapi.ordercloud.io/v1/me/productcollections/wishlist/products HTTP/1.1
Authorization: Bearer INSERT_ACCESS_TOKEN_HERE
Content-Type: application/json; charset=UTF-8
We may end up changing our mind, and wanting to remove products from our Wishlist. To remove a product from our Wishlist, we will call DELETE /me/productcollections/{productCollectionID}/{productID}
.
DELETE https://sandboxapi.ordercloud.io/v1/me/productcollections/wishlist/enterprise-product-id HTTP/1.1
Authorization: Bearer INSERT_ACCESS_TOKEN_HERE
Content-Type: application/json; charset=UTF-8
That's it! It's that simple. Product Collections make building wishlist-like features for B2X commerce easy. Now that you have a basic understanding of how Product Collections work, you can take this knowledge and build a UI in your buyer application for buyer users to create and manage their wishlists.
This implementation is one of the many permutations of the Product Collections resource. There are many ways to utilize Product Collections and a "wishlist" feature is just one of them. A few more example features that could make use of Product Collections are "Save for later" or "Favorites".
Product Collections are:
GET /me/productcollections/{productCollectionID}/products
.
If visibility is restored, the product will begin returning from the aforementioned call once again.Check out the key highlights from the Knowledge Base article introducing Product Collections for more context.