Add Gift To Cart
This endpoint is used to add a product that has been gifted to the shopping cart, after which the customer can be redirected to the shopping cart page in order to complete the purchase of that product as a solo.
:::tip
The add gift to cart endpoint has been implemented in the Gifting Web Component, and It's all setup to save developer's time and effort.
:::
Payload authenticated
Response
Usage
To perform the action of adding a product that has been gifted to the shopping cart, the developer may call the method addGiftToCart
as follows.
salla.product.addGiftToCart({
product_id: 258741,
payload: Object,
withRedirect: false
}).then((response) => {
/* add your code here */
});
Events
This endpoint may trigger two events, the onAddGiftToCartSucceeded and onAddGiftToCartFailed events.
onAddGiftToCartSucceeded
This event is triggered when the action of adding a product that has been gifted to the shopping cart is done without having any errors coming back from the backend.
salla.product.event.onAddGiftToCartSucceeded((response) => {
console.log(response)
});
onAddGiftToCartFailed
This event is triggered when the action of adding a product that has been gifted to the shopping cart is not completed and an error has occurred.
salla.product.event.onAddGiftToCartFailed((errorMessage) => {
console.log(errorMessage)
});