Alokai

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

NameRequiredTypeDescription
contextRequiredCommercetoolsIntegrationContext
paramsRequiredRemoveFromMyShoppingListParams
customQueryOptionalCustomQuery

Referenced Types

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);

On this page