Funnels
Offers before, during, and after the purchase: get the next one, accept it, or skip it.
A funnel has three phases: pre-purchase, mid-purchase and
post-purchase. In each phase you fetch the next step, then accept it or skip
it, and fetch again until step is null. For the full flow, with one example
per phase, see Run a funnel.
Gets the next pre-purchase offer for the cart. step comes back null once the
customer has seen every offer.
Method parameters
cartIdRequiredstringID of the cart, usually subbly.cart.id.
paramsoptionalFunnelsResourceParamsExtra data to include.
ReturnsPromise<FunnelFetchResponse>
The next offer, or an empty one.
Show the next offer
Accepts a pre-purchase offer and adds its products to the cart.
The cart it returns is a plain object, not the subbly.cart model, so
subbly.cart still holds the old contents. Reload it with subbly.cart.load().
Method parameters
cartIdRequiredstringID of the cart.
funnelStepIdRequirednumberID of the step the customer accepted, from step.id.
payloadRequiredFunnelAcceptPayloadThe products the customer took.
paramsoptionalCartResourceParamsExtra data to include on the cart that comes back.
ReturnsPromise<SubblyCart>
The cart after the offer went in.
Accept an offer
Skips a pre-purchase offer. Subbly records the refusal, so the next fetch moves on to the following step.
Method parameters
cartIdRequiredstringID of the cart.
funnelStepIdRequirednumberID of the step the customer skipped.
ReturnsPromise<void>
Nothing. The response body is empty.
Skip an offer
Clears which pre-purchase offers the customer accepted or skipped, so the sequence starts from the first step again. Only the pre-purchase phase has this.
Method parameters
cartIdRequiredstringID of the cart.
ReturnsPromise<unknown>
Nothing you need to read. Treat the response as empty.
Start the offers again
Gets the next mid-purchase offer for the cart. Show these while the customer works through checkout.
Method parameters
cartIdRequiredstringID of the cart.
paramsoptionalFunnelsResourceParamsExtra data to include.
ReturnsPromise<FunnelFetchResponse>
The next offer, or an empty one.
Show the next offer
Accepts a mid-purchase offer and adds its products to the cart. As with the
pre-purchase accept, reload subbly.cart afterwards.
Method parameters
cartIdRequiredstringID of the cart.
funnelStepIdRequirednumberID of the step the customer accepted.
payloadRequiredFunnelAcceptPayloadThe products the customer took.
paramsoptionalCartResourceParamsExtra data to include on the cart that comes back.
expandoptionalstring[]Cart relations to include.
ReturnsPromise<SubblyCart>
The cart after the offer went in.
Accept an offer
Skips a mid-purchase offer so the next fetch moves on.
Method parameters
cartIdRequiredstringID of the cart.
funnelStepIdRequirednumberID of the step the customer skipped.
ReturnsPromise<void>
Nothing. The response body is empty.
Skip an offer
Gets the next post-purchase offer for the cart. These run only after
subbly.checkout.purchase succeeds, on the thank-you page.
Method parameters
cartIdRequiredstringID of the cart that was paid.
paramsoptionalFunnelsResourceParamsExtra data to include.
ReturnsPromise<FunnelFetchResponse>
The next offer, or an empty one.
Show the next offer after checkout
Accepts a post-purchase offer and charges it as a new purchase on the card the customer already used. Unlike the other two accepts, this one returns the invoice, subscription and orders it created. Needs an authenticated customer.
Method parameters
cartIdRequiredstringID of the cart that was paid.
funnelStepIdRequirednumberID of the step the customer accepted.
payloadRequiredFunnelPostAcceptPayloadThe products taken, and anything the purchase still needs.
paramsoptionalCartResourceParamsExtra data to include in the response.
ReturnsPromise<FunnelPostAcceptResponse>
What the extra purchase created.
Accept a post-purchase offer
Skips a post-purchase offer so the next fetch moves on.
Method parameters
cartIdRequiredstringID of the cart that was paid.
funnelStepIdRequirednumberID of the step the customer skipped.
ReturnsPromise<void>
Nothing. The response body is empty.
Skip an offer