๐งพ Wishlist Item Fields
This guide explains how wishlist item fields are returned and controlled using the items_fields[]
and fields
query parameters.
โ Default Fields Returnedโ
When includeWishlistItems: true
is enabled in the plugin config, each wishlist item includes the following by default:
[
"id",
"product_id",
"wishlist_id",
"created_at",
"updated_at",
"deleted_at",
"product_variant.*",
"product_variant.prices.*",
"product_variant.calculated_price",
"product_variant.product.thumbnail",
];
These defaults apply when retrieving or listing wishlists using:
๐ Customizing Returned Fieldsโ
1. items_fields[]
(wishlist-level endpoints)โ
Used to control the fields returned for each wishlist item when calling:
This does not affect wishlist-level fields โ only the embedded items.
- Using SDK
- Using REST (Medusa SDK or fetch)
const retrievedWishlist = await sdk.alphabite.wishlist.list({
fields: ["id"]
items_fields: ["id", "product_variant.id"],
});
import { RetrieveWishlistInput, RetrieveWishlistOutput } from "@alphabite/medusa-sdk";
const retrievedWishlist = await sdk.client.fetch<RetrieveWishlistOutput>(`/store/wishlists`, {
method: "GET",
query: {
fields: ["id"],
items_fields: ["id", "product_variant.id"],
} as Omit<RetrieveWishlistInput, "id">,
});
Returns only id
and the product_variant_id
for each item.
{
data: [
{
id: "wl_123",
items: [
{
id: "wli__456",
product_variant: {
id: "variant_789",
},
},
],
},
{
id: "wl_456",
items: [
{
id: "wli__456",
product_variant: {
id: "variant_123",
},
},
],
},
],
count: 2,
skip: 0,
take: 0,
totalPages: 1,
currentPage: 1,
nextPage: 1,
prevPage: 1,
};
2. fields
(item-level endpoints)โ
Used to control the fields returned for items directly when calling:
- Using SDK
- Using REST (Medusa SDK or fetch)
const retrievedWishlist = await sdk.alphabite.wishlist.listItems({
fields: ["id", "product_variant.id"],
});
import { RetrieveWishlistInput, RetrieveWishlistOutput } from "@alphabite/medusa-sdk";
const retrievedWishlist = await sdk.client.fetch<RetrieveWishlistOutput>(`/store/wishlists`, {
method: "GET",
query: {
fields: ["id", "product_variant.id"],
} as Omit<RetrieveWishlistInput, "id">,
});
{
data: [
{
id: "wli__456",
product_variant: {
id: "variant_789",
},
},
{
id: "wli__456",
product_variant: {
id: "variant_123",
},
},
],
count: 2,
skip: 0,
take: 0,
totalPages: 1,
currentPage: 1,
nextPage: 1,
prevPage: 1,
};
Controls the shape of the item records returned in the list.
๐ง fields
on Wishlist Itselfโ
When calling:
The fields
param applies to wishlist fields only โ not items.
To control item fields, use items_fields[]
in combination.
- Using SDK
- Using REST (Medusa SDK or fetch)
const retrievedWishlist = await sdk.alphabite.wishlist.list({
fields: ["id", "name"],
items_fields: ["id", "product_variant.id"],
});
import { RetrieveWishlistInput, RetrieveWishlistOutput } from "@alphabite/medusa-sdk";
const retrievedWishlist = await sdk.client.fetch<RetrieveWishlistOutput>(`/store/wishlists`, {
method: "GET",
query: {
fields: ["id", "name"],
items_fields: ["id", "product_variant.id"],
} as Omit<RetrieveWishlistInput, "id">,
});
id
andname
on the wishlistid
andcalculated_price
on each product variant in items
๐ Relatedโ
- Listing Wishlists ๐
- Retrieving a Wishlist ๐
- Listing Wishlist Items ๐
- Wishlist API Reference