removeFromMyShoppingList
Method for removing a product from Shopping List.
By default, it uses the addToMyShoppingListDefaultQuery GraphQL query.
It's using the same default query as addToMyShoppingList which has mutation updateShoppingList.
Signature
declare function removeFromMyShoppingList(
context: CommercetoolsIntegrationContext,
params: RemoveFromMyShoppingListParams,
customQuery?: CustomQuery
): Promise<RemoveFromMyShoppingListResponse>;Parameters
| Name | Required | Type | Description |
|---|---|---|---|
context | Required | CommercetoolsIntegrationContext | |
params | Required | RemoveFromMyShoppingListParams | |
customQuery | Optional | CustomQuery |
Referenced Types
- CommercetoolsIntegrationContext
- RemoveFromMyShoppingListParams
- CustomQuery
- RemoveFromMyShoppingListResponse
Examples
Removing a product from Shopping List:
const REMOVE_PRODUCT_SHOPPING_LIST_PARAMS = {
id: 'test-id',
version: 'test-version',
lineItems: [
{
id 'some-id',
quantity: 1
}
]
};
const { wishlist } = await sdk.commerce.removeFromMyShoppingList(REMOVE_PRODUCT_SHOPPING_LIST_PARAMS);Creating a custom GraphQL query for the method in middleware.config.ts:
module.exports = {
export const integrations = {
ct: {
// ...
customQueries: {
'remove-from-my-shopping-list-custom-query': ({ variables, metadata }) => {
return {
variables,
query: `
mutation updateShoppingList($id: String!, $version: Long!, $actions: [MyShoppingListUpdateAction!]!, $acceptLanguage: [Locale!], $currency: Currency!, $country: Country!) {
wishlist: updateMyShoppingList(id: $id, version: $version, actions: $actions) {
${metadata}
}
}`
};
}
}
}
}
};Using a custom GraphQL query for the method: customQuery parameter to leverage the custom GraphQL query from the previous example.
const customQuery = {
createMyShoppingList: 'create-my-shopping-list-custom-query',
metadata: 'id version lineItems { id sku quantity }'
};
const { wishlist } = await sdk.commerce.removeFromMyShoppingList(REMOVE_PRODUCT_SHOPPING_LIST_PARAMS, customQuery);