addGiftCertificateToBasket
Adds a gift certificate item to an existing basket.
This method communicates with the addGiftCertificateToBasket endpoint of the Vue Storefront API Middleware. In turn, it receives data from the addGiftCertificateItemToBasket or the Add a gift certificate item to a basket endpoints exposed by SCAPI / OCAPI depending on the middleware configuration.
Possible Responses
400 | InvalidGiftCertificateItemAmountException - Indicates that the gift certificate item amount is negative.
Signature
export declare function addGiftCertificateToBasket(
props: BasketGiftCertificateAddParams & {
basketId?: string;
}
): Promise<import("commerce-sdk/dist/checkout/checkout").ShopperBaskets.Basket>;Parameters
| Name | Required | Type | Description |
|---|---|---|---|
props | Required | BasketGiftCertificateAddParams & { basketId?: string; } | Parameter object which can be used with this method. Refer to its type definition to learn about possible properties. |
Returns
Returns a representation of a Basket object.
Referenced Types
BasketGiftCertificateAddParamsShopperBaskets.Basket
Examples
Adding a gift certificate item to an existing basket by amount and recipientEmail.
import { sdk } from '~/sdk.config.ts';
const basket = await $sdk.commerce.getBasket();
const updatedBasket = await sdk.commerce.addGiftCertificateToBasket({
amount: 100,
recipientEmail: 'testEmail@provider.com',
recipientName: 'Recipient Name'
});Adding a gift certificate item to an existing basket with optional fields by amount and recipientEmail.
import { sdk } from '~/sdk.config.ts';
const basket = await $sdk.commerce.getBasket();
const updatedBasket = await sdk.commerce.addGiftCertificateToBasket({
amount: 100,
recipientEmail: 'testEmail@provider.com',
recipientName: 'Recipient Name',
senderName: 'Sender Name',
message: 'Happy Birthday!',
shipmentId: 'me'
});