Wishlist

Created

Overview#

Wishlists allow shoppers to add products to the list in one click, review those items at a later time and keep track of price and other product information. In this article we describe how to set it up.

Reasons customers love wishlists#

  • Saving items for later so that they are not lost or forgotten
  • Tracking items that are currently out of the shopper's price range but might be on sale in the future
  • Creating lists for special events such as a holiday or a birthday

In addition it allows e-comm merchants to limit cart abandonment by encouraging customers to use the wishlist for item organization instead of using the cart.

Wishlist functionality#

Which products can be added to the wishlist?#

Any product can be added to a wishlist, including ones currently out of stock. Currently, wishlists support up to 10000 products in a single list.

One wishlist per customer#

Each customer can have one wishlist connected to their account. The customer must be logged in. Read here on how to handle customer registration, login and password reset email flow.

Add & remove products from a wishlist#

Customers can add/remove products to the wishlist from any place in the purchasing journey: product listing page, product details page, basket, checkout etc. The place from which the end customer adds products to a wishlist is determined by the frontend implementation. At the moment, it is only possible to add/remove products from a wishlist one item at a time.

Getting wishlist information#

You can load the wishlist via the customer query, see the example below. For more wishlist fields, see API docs.

1 2 3 4 5 6 7 8 9 10 11 12 13 customer { wishlists { id isDefault items (page:1, limit: 2) { id name price { formattedValue } } } }

As in the example above it is possible to paginate the items using the paginator query parameters.

If a wishlist is found the response will be:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 { "data": { "customer": { "wishlists": [ { "id": 1, "isDefault": true, "items": [ { "id": 1, "name": "Test Product", "price": { "formattedValue": "94.50 SEK" } } ] } ] } } }

Adding a product to a wishlist#

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 mutation { addWishlistItem(displayItemId: {displayItemId}) { wishlist { id name items (limit: 10, page: 1) { id name } } userErrors { path message } } }

Where {displayItemId} is the id of the DisplayItem

Validation errors#

The endpoint has validation for several cases, including:

Display item not found#

1 2 3 4 5 6 7 8 9 10 11 12 { "data": { "addWishlistItem": { "userErrors": [ { "path": ["addWishlistItem", "displayItem", "id"], "message": "Could not find a display item with id 1" } ] } } }

Duplicate display in wishlist#

1 2 3 4 5 6 7 8 9 10 11 12 { "data": { "addWishlistItem": { "userErrors": [ { "path": ["addWishlistItem", "displayItem"], "message": "Cannot add display 1 to wishlist 1: duplicate item" } ] } } }

Item belongs to other store type#

1 2 3 4 5 6 7 8 9 10 11 12 { "data": { "addWishlistItem": { "userErrors": [ { "path": ["addWishlistItem", "displayItem", "id"], "message": "Invalid store type: WHOLESALE, expected store type: DIRECT_TO_CONSUMER" } ] } } }

Success#

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 { "data": { "addWishlistItem": { "wishlist": { "id": 1, "name": "DEFAULT", "items": [ { "id": 6, "name": "Test Product Discounted" } ] }, "userErrors": [] } } }

Removing a product from a wishlist#

1 2 3 4 5 6 7 8 9 10 11 12 13 14 mutation { removeWishlistItem(displayItemId: 1, wishlistId: 1) { wishlist { name items(limit: 10, page: 1) { id } } userErrors { path message } } }

Validation errors#

The endpoint provides validation for several cases, including:

Display item not found

1 2 3 4 5 6 7 8 9 10 11 12 { "data": { "removeWishlistItem": { "userErrors": [ { "path": ["removeWishlistItem", "displayItem", "id"], "message": "Could not find a display item with id 10000" } ] } } }

Display item not found in wishlist

1 2 3 4 5 6 7 8 9 10 11 12 { "data": { "removeWishlistItem": { "userErrors": [ { "path": ["removeWishlistItem", "wishlist", "id"], "message": "Could not find a wishlist item with wishlist id '1' and display id '3'" } ] } } }

Wishlist not found / current user is not owner of selected wishlist

1 2 3 4 5 6 7 8 9 10 11 12 { "data": { "removeWishlistItem": { "userErrors": [ { "path": ["removeWishlistItem", "wishlistId"], "message": "Wishlist with id 3 not found" } ] } } }

Success

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 { "data": { "removeWishlistItem": { "wishlist": { "name": "DEFAULT", "items": [ { "id": 6, "name": "Test Product Discounted" } ] }, "userErrors": [] } } }