Subscribe Back In Stock

Subscribes the current user to back-in-stock alerts for the selected product.

Description

The subscribeBackInStock() action subscribes the current customer to a back-in-stock notification for the product currently in context.

Function Signature

await Superfans.actions.subscribeBackInStock();
ParameterTypeRequiredDescription
NilNilNilThis action does not require any parameter. The SDK uses the current product and variant context.

Structure of Response

StatusResponse
Success{ "status": "success", "message": "Back in stock subscription created successfully" }
Unexpected Error{ "status": "error", "errorId": 500, "errorHandle": "unknown-error", "message": "Something unexpected happened" }

Example Usage

await Superfans.actions.subscribeBackInStock();

Best Practices

  1. Show this CTA only when the current variant is unavailable.
  2. Re-read Superfans.variables.product inside onVariantChanged before deciding whether to show the subscribe button.

Caveats

  1. This action uses the current product context; it does not accept a product or variant ID in the payload.
  2. The user may need to be logged in or have notifications enabled depending on app configuration.

Did this page help you?