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()
ParameterTypeRequiredDescription
NilNilNilThis action does not require any parameter.

Structure of Response

StatusResponse
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

  1. Use after all validation checks — e.g., ensuring products are in stock, customer data is filled, and coupon validation is complete.
  2. Pair with disableCheckoutButton() — always disable checkout during validation and re-enable it after success.
  3. Provide visual feedback — use showToast() or showAlert() to inform users when checkout becomes available.
  4. Keep UI consistent — make sure other interactive elements reflect the checkout availability state.

Caveats

  1. Works only on native cart or checkout screens that include a checkout button.
  2. Does not automatically validate cart contents — logic must be handled separately.
  3. Multiple calls have no adverse effects but may overwrite pending disable actions.