Skip to main content

IWishlistModuleService Reference

This section of the documentation provides a reference to the IWishlistModuleService interface’s methods. This is the interface developers use to use the functionalities provided by the Wishlist Module.
You should only use the methods in this reference when implementing complex customizations. For common cases, check out available workflows instead.
The main service interface for the Wishlist Module.

Methods


createWishlists

This section provides a reference to the createWishlists method. This belongs to the Wishlist Module.

createWishlists(data, sharedContext?): Promise<WishlistDTO[]>

This method creates wishlist items.

Example

const wishlists = await wishlistModuleService.createWishlists([
  {
    reference: "product",
    reference_id: "prod_123",
    customer_id: "cus_123",
  },
])

Parameters

data
CreateWishlistDTO[]
required
The wishlist items to be created.
sharedContext
Context
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise
Promise<WishlistDTO[]>
The created wishlist items.

createWishlists(data, sharedContext?): Promise<WishlistDTO>

This method creates a wishlist item.

Example

const wishlist = await wishlistModuleService.createWishlists({
  reference: "product",
  reference_id: "prod_123",
  customer_id: "cus_123",
})

Parameters

data
CreateWishlistDTO
required
The wishlist item to be created.
sharedContext
Context
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise
Promise<WishlistDTO>
The created wishlist item.

updateWishlists

This section provides a reference to the updateWishlists method. This belongs to the Wishlist Module.

updateWishlists(id, data, sharedContext?): Promise<WishlistDTO>

This method updates an existing wishlist item.

Example

const wishlist = await wishlistModuleService.updateWishlists("wish_123", {
  reference_id: "prod_456",
})

Parameters

id
string
required
The ID of the wishlist item.
data
UpdateWishlistDTO
required
The attributes to update in the wishlist item.
sharedContext
Context
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise
Promise<WishlistDTO>
The updated wishlist item.

deleteWishlists

This section provides a reference to the deleteWishlists method. This belongs to the Wishlist Module.

deleteWishlists(ids, sharedContext?): Promise<void>

This method deletes wishlist items by their IDs.

Example

await wishlistModuleService.deleteWishlists(["wish_123", "wish_321"])

Parameters

ids
string[]
required
The IDs of the wishlist items.
sharedContext
Context
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise
Promise<void>
Resolves when the wishlist items are deleted successfully.

deleteWishlists(id, sharedContext?): Promise<void>

This method deletes a wishlist item by its ID.

Example

await wishlistModuleService.deleteWishlists("wish_123")

Parameters

id
string
required
The ID of the wishlist item.
sharedContext
Context
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise
Promise<void>
Resolves when the wishlist item is deleted successfully.

retrieveWishlist

This section provides a reference to the retrieveWishlist method. This belongs to the Wishlist Module. This method retrieves a wishlist item by its ID.

Example

const wishlist = await wishlistModuleService.retrieveWishlist("wish_123")

Parameters

id
string
required
The ID of the wishlist item.
config
FindConfig<WishlistDTO>
The configurations determining how the wishlist item is retrieved.
sharedContext
Context
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise
Promise<WishlistDTO>
The retrieved wishlist item.

listWishlists

This section provides a reference to the listWishlists method. This belongs to the Wishlist Module. This method retrieves a paginated list of wishlist items based on optional filters and configuration.

Example

To retrieve a customer’s wishlist:
const wishlists = await wishlistModuleService.listWishlists({
  customer_id: "cus_123",
})
To retrieve wishlist items for specific products:
const wishlists = await wishlistModuleService.listWishlists({
  reference_id: ["prod_123", "prod_456"],
})
By default, only the first 15 records are retrieved. You can control pagination by specifying the skip and take properties of the config parameter:
const wishlists = await wishlistModuleService.listWishlists(
  {
    customer_id: "cus_123",
  },
  {
    take: 20,
    skip: 2,
  }
)

Parameters

filters
FilterableWishlistProps
The filters to apply on the retrieved wishlist items.
config
FindConfig<WishlistDTO>
The configurations determining how the wishlist item is retrieved.
sharedContext
Context
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise
Promise<WishlistDTO[]>
The list of wishlist items.

listAndCountWishlists

This section provides a reference to the listAndCountWishlists method. This belongs to the Wishlist Module. This method retrieves a paginated list of wishlist items along with the total count of available wishlist items satisfying the provided filters.

Example

To retrieve a customer’s wishlist with count:
const [wishlists, count] = await wishlistModuleService.listAndCountWishlists({
  customer_id: "cus_123",
})
By default, only the first 15 records are retrieved. You can control pagination by specifying the skip and take properties of the config parameter:
const [wishlists, count] = await wishlistModuleService.listAndCountWishlists(
  {
    customer_id: "cus_123",
  },
  {
    take: 20,
    skip: 2,
  }
)

Parameters

filters
FilterableWishlistProps
The filters to apply on the retrieved wishlist items.
config
FindConfig<WishlistDTO>
The configurations determining how the wishlist item is retrieved.
sharedContext
Context
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise
Promise<[WishlistDTO[], number]>
The list of wishlist items along with their total count.

softDeleteWishlists

This section provides a reference to the softDeleteWishlists method. This belongs to the Wishlist Module. This method soft deletes wishlist items by their IDs.

Example

await wishlistModuleService.softDeleteWishlists([
  "wish_123",
  "wish_321",
])

Parameters

wishlistIds
string[]
required
The IDs of the wishlist items.
config
SoftDeleteReturn<TReturnableLinkableKeys>
An object that is used to specify an entity’s related entities that should be soft-deleted when the main entity is soft-deleted.
sharedContext
Context
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise
Promise<void | Record<string, string[]>>
An object that includes the IDs of related records that were also soft deleted. If there are no related records, the promise resolves to void.

restoreWishlists

This section provides a reference to the restoreWishlists method. This belongs to the Wishlist Module. This method restores soft deleted wishlist items by their IDs.

Example

await wishlistModuleService.restoreWishlists(["wish_123", "wish_321"])

Parameters

wishlistIds
string[]
required
The IDs of the wishlist items.
config
RestoreReturn<TReturnableLinkableKeys>
Configurations determining which relations to restore along with each of the wishlist item.
sharedContext
Context
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise
Promise<void | Record<string, string[]>>
An object that includes the IDs of related records that were restored. If there are no related records restored, the promise resolves to void.