You are reading the documentation for SDK v2, which is no longer the latest version. Switch to current
removeFromMyShoppingList
Method for removing a product from Shopping List.
This method sends a POST request to the removeFromMyShoppingList endpoint. and removes a product from Shopping List.
The default GraphQL query used by this method can be found here It's using the same default query as addToMyShoppingList which has mutation updateShoppingList.
Signature
export declare function removeFromMyShoppingList<Res extends PartialRemoveMyShoppingListResponse = RemoveFromMyShoppingListResponse>(
params: RemoveFromMyShoppingListParams,
options?: MethodOptions<CustomQuery<"updateShoppingList">>
): Promise<Res>;Parameters
| Name | Required | Type | Description |
|---|---|---|---|
params | Required | RemoveFromMyShoppingListParams | Parameter object which can be used with this method. Refer to its type definition to learn about possible properties. |
options | Optional | MethodOptions<CustomQuery<"updateShoppingList">> | Options that can be passed to additionally configure the request or customize the logic in a plugin. |
Returns
Returns a representation of the RemoveFromMyShoppingListResponse.
Referenced Types
- PartialRemoveMyShoppingListResponse
- RemoveFromMyShoppingListResponse
- RemoveFromMyShoppingListParams
- MethodOptions
- CustomQuery
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.js:
module.exports = {
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.
import { sdk } from '~/sdk.config.ts';
const customQuery = {
createMyShoppingList: 'create-my-shopping-list-custom-query',
metadata: 'id version lineItems { id sku quantity }'
};
type MyResponseType = {
wishlist: {
id: string;
version: number;
lineItems: Array<{
id: string;
quantity: number;
}>
}
}
const { wishlist } = await sdk.commerce.removeFromMyShoppingList<MyResponseType>(REMOVE_PRODUCT_SHOPPING_LIST_PARAMS, { customQuery });