Product availability
This endpoint helps the customer in the absence of a product's stock. AÂ customer may need to subscribe to that product availability subscription list in order to be notified once the stock is available for purchase again.Â
:::tip
The product availability endpoint has been implemented in the Product Availability Web Component, and it's ready for use.
:::
Payload
Response
Usage
To enable the customer to subscribe to a product and get notification once its stock is available, the developer can use the method availabilitySubscribe()
to receive the customer's contact information and add them to the product availability subscription list.
Logged User
// product id: 12345
salla.product.availabilitySubscribe({
id: 12345
}).then((response) => {
/* add your code here */
});
// TIP: short version
salla.product.availabilitySubscribe(12345).then((response) => {
/* add your code here */
});
Guest (Mobile)
salla.product.availabilitySubscribe({
id: 12345,
country_code: "+966",
mobile: "55558887",
}).then((response) => {
/* add your code here */
});
Guest (Email)
salla.product.availabilitySubscribe({
id: 12345,
email: "[email protected]",
}).then((response) => {
/* add your code here */
});
Events
This endpoint may trigger two events, the onAvailabilitySubscribed and onAvailabilitySubscribedFailed events.
onAvailabilitySubscribed
This event is triggered when subscribing a customer to a product availability subscription list is done without having any errors coming back from the backend.
salla.event.product.onAvailabilitySubscribed((response) => {
console.log(response)
});
onAvailabilitySubscribedFailed
This event is triggered when subscribing a customer to a product availability subscription list is not completed and an error has occurred.
salla.event.product.onAvailabilitySubscribedFailed((errorMessage) => {
console.log(errorMessage)
});