Enable Checkout Button
Enables checkout button on the cart
Description
The enableCheckoutButton() action re-enables the native Checkout button in the cart screen of the app.
Use this method once you’ve verified all conditions (like cart eligibility) and want to allow the customer to proceed to checkout.
This is typically used in workflows where checkout was previously disabled for validation or safety reasons.
Function Signature
VajroSDK.actions.enableCheckoutButton()| Parameter | Type | Required | Description |
|---|---|---|---|
| Nil | Nil | Nil | This action does not require any parameter. |
Structure of Response
| Status | Response |
|---|---|
| Success | { "status": "success", "message": "Checkout button enabled successfully" } |
| Failed | { "status": "failed", "message": "Checkout button not enabled due to additional constraints" } |
| Unexpected Error | { "status": "error", "errorId": 500, "errorHandle": "unknown-error", "message": "Something unexpected happened" } |
Example Usage
const MINIMUM_ORDER_AMOUNT = 50; // Minimum order amount to enable checkout
let cartTotal = VajroSDK.variables.cart.subtotal || 0;
function updateCheckoutButton() {
cartTotal = VajroSDK.variables.cart.subtotal || 0;
if (cartTotal >= MINIMUM_ORDER_AMOUNT) {
VajroSDK.actions.enableCheckoutButton();
}
else {
VajroSDK.actions.disableCheckoutButton()
}
}
VajroSDK.listeners.onCartUpdated(() => {
updateCheckoutButton();
});
Best Practices
- Use after all validation checks — e.g., ensuring products are in stock, customer data is filled, and coupon validation is complete.
- Pair with disableCheckoutButton() — always disable checkout during validation and re-enable it after success.
- Provide visual feedback — use showToast() or showAlert() to inform users when checkout becomes available.
- Keep UI consistent — make sure other interactive elements reflect the checkout availability state.
Caveats
- Works only on native cart or checkout screens that include a checkout button.
- Does not automatically validate cart contents — logic must be handled separately.
- Multiple calls have no adverse effects but may overwrite pending disable actions.
Updated about 1 month ago