A react hook that exposes pelcro global store and actions.
You can use
usePelcro outside react components via the
Lets you override internal implementations inside the pelcro global store.
The currently open pelcro modal.
Can be set by
The currently selected product, contains the product details and all the plans configured on the platform.
Can be set by
The currently selected plan.
Can be set by
When true, the proceeding subscription will be a gifted one, and the
GiftCreateModal will open up to gather the donee information.
The string code of a gift, when set with a valid gift code,
AddressSelectModal redeems the subscription without going to the payment form.
Used by the
SubscriptionRenewModal to renew a specific subscription. When set with a valid renewable subscription ID, user is redirected to pay for the given subscription renewal.
When set with a valid address ID, it'll be preselected in the next payment for a plan/ecommerce where address is required.
The ecommerce cart array. Contains the current user's cart items. Also Persisted in local storage.
The current ecommerce order items. this field is populated once the user starts the checkout flow, it can either be an array of items, which happens in the case of checking out using the cart view, or a single item object, which happens in the case of clicking the quick purchase button of an e-commerce item.
The global store setter. Takes a partial state and merges it with the current state
Resets all the state without closing the current modal.
Called with a valid view ID to switch to the right modal.
Resets the view state (closes the modal) & resets all the state.
When called, directs to the appropriate payment modal according to the current state. Resets the view otherwise.
|SubscriptionRenewModal||When both |
When called, directs to the appropriate address modal according to the current state.
|AddressSelectModal||When the user has at least one shipping address.|
|AddressCreateModal||When user doesn't have any address yet.|
Sets the selected product state. Called with a valid product id
Sets the selected plan state. Called with a valid plan id
Adds a new item to the user's cart. If the item already exists, it adds to its quantity. Called with a valid SKU id
Removes an item from the user's cart. If the item's quantity is more than 1, it decrements the quantity. Called with a valid SKU id
Instantly starts the checkout flow for a single ecommerce item. Called with a valid SKU id
Returns true when user is authenticated, false otherwise.
Logs the current user out & switches to
LoginModal, if authenticated.
Takes a callback function and executes it immediately if your Pelcro site is already loaded, or when it finally loads.
Takes a callback function and executes it immediately if the user object is loaded, or when it finally loads.
Takes a callback function and executes it immediately if the ecommerce products are loaded, or when they finally load.