$customHeader
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 4 Next »


All API calls are synchronous unless you specify an optional last parameter at the end of the function call. Below we'll show you how to make an asynchronous call.
Example of synchronous code

// Make the API call 
var shippingEstimates = estimateShipping();
// Consume the result 
for (var = i; i < shippingEstimates.length; i++){
   // Do something with the estimate
}

Example of asynchronous code

// Define a callback function 
function myCallbackFunction(shippingEstimates){
    for (var = i; i < shippingEstimates.length; i++) {
        // Do something with the estimate
    }
}

// Make the asynchronous call 
estimateShipping({'async': true, 'onComplete': myCallbackFunction});

Our recommendation is to make the the shipping estimate call asynchronous due to the time it can take calculate estimates. Make sure that you give the customer a visual indication that shipping estimates are being calculated. We do not recommend making calls that manipulate the cart asynchronous as it could cause inconsistancies in the global cart variables contents.


  • No labels