Last updated

setOnCheckout()

Sets a custom checkout handler function.

Signature

window.FairShareSDK.setOnCheckout(handler);

Parameters

ParameterTypeDescription
handlerfunctionAsync function to handle checkout

Example

// Set custom checkout handler
window.FairShareSDK.setOnCheckout(async () => {
  console.log('Custom checkout triggered');
  
  // Validate cart before checkout
  const cart = await window.FairShareSDK.getCart();
  if (cart.items.length === 0) {
    alert('Your cart is empty!');
    return;
  }
  
  // Redirect to custom checkout
  window.location.href = '/custom-checkout';
});

Get Current Handler

const handler = window.FairShareSDK.getOnCheckout();