To make development easier many of the methods in the checkoutapi.js file automatically submit the global cart variable parameter to the server as well as update it on the return. This dramatically reduces the complexity of coding your checkout as well as the scoping issues of trying to pass a cart object around to other methods. The following methods automatically update the global cart variable:
addItems
applyCoupon
applyGiftCertificate
clearItems
establishCustomerProfile
getCartInstance
logoutCustomerProfile
removeCoupon
removeItems
removeItem
updateCart
updateItems