Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagexml
linenumberstrue
<script type='text/javascript'>
	function display_cart(){
	   if(my_cart){
		var total = my_cart.totalLocalizedFormatted; // make it pretty
		var itemCount = my_cart.items ? my_cart.items.length : 0;
	   
	    // now do something with these values... 
	   }	
	}
</script>
<script type='text/javascript' src='//secure.ultracart.com/cgi-bin/UCJavaScript?merchantid=DEMO&type=json&cartvar=my_cart&callback=display_cart'></script>

...


Code Block
languagejs
var my_cart = {
    "merchantId": "DEMO",
    "items": [],
    "cartId": "806F511B57E2D90153D30FF833020A00",
    "paymentMethod": "Unknown",
    "creditCardTypes": ["AMEX", "Diners Club", "Discover", "JCB", "MasterCard", "VISA"],
    "creditCardType": "",
    "creditCardNumber": "",
    "creditCardExpirationMonth": 0,
    "creditCardExpirationYear": 0,
    "creditCardVerificationNumber": "",
    "collectCreditCardVerificationNumber": true,
    "purchaseOrderNumber": "",
    "billToFirstName": "",
    "billToLastName": "",
    "billToTitle": "",
    "billToCompany": "",
    "billToAddress1": "",
    "billToAddress2": "",
    "billToCity": "",
    "billToState": "",
    "billToPostalCode": "",
    "billToCountry": "United States",
    "billToDayPhone": "",
    "billToEveningPhone": "",
    "email": "",
    "emailConfirm": "",
    "shipToFirstName": "",
    "shipToLastName": "",
    "shipToTitle": "",
    "shipToCompany": "",
    "shipToAddress1": "",
    "shipToAddress2": "",
    "shipToCity": "",
    "shipToState": "",
    "shipToPostalCode": "",
    "shipToCountry": "United States",
    "shipToPhone": "",
    "shipToEveningPhone": "",
    "shippingMethod": "",
    "needShipping": false,
    "subtotal": 0,
    "subtotalDiscount": 0,
    "subtotalWithDiscount": 0,
    "taxRate": 0,
    "tax": 0,
    "taxableSubtotal": 0,
    "taxableSubtotalDiscount": 0,
    "taxableSubtotalWithDiscount": 0,
    "shippingHandling": 0.00,
    "shippingHandlingDiscount": 0,
    "shippingHandlingWithDiscount": 0.00,
    "giftCharge": 0,
    "giftWrapCost": 0.00,
    "gift": false,
    "surcharge": 0,
    "total": 0,
    "buysafeBondAvailable": false,
    "buysafeBondFree": false,
    "buysafeBondWanted": true,
    "taxExempt": false,
    "shipToResidential": true,
    "mailingListOptIn": true,
    "specialInstructions": "",
    "screenBrandingThemeCode": "CSTM",
    "advertisingSource": "",
    "coupons": [],
    "hasPayPal": false,
    "payPalCompatible": false,
    "hasGoogleCheckout": false,
    "googleCheckoutCompatible": false,
    "loggedIn": false,
    "insureShipAvailable": false,
    "insureShipSeparate": false,
    "insureShipWanted": false,
    "taxCounty": "",
    "liftGate": false,
    "storeCreditCard": false,
    "hasAmazon": false,
    "needPayment": true,
    "currencyCode": "USD",
    "subtotalLocalized": 0.00,
    "subtotalDiscountLocalized": 0.00,
    "subtotalWithDiscountLocalized": 0.00,
    "taxLocalized": 0.00,
    "taxableSubtotalLocalized": 0.00,
    "taxableSubtotalDiscountLocalized": 0.00,
    "taxableSubtotalWithDiscountLocalized": 0.00,
    "shippingHandlingLocalized": 0.00,
    "shippingHandlingDiscountLocalized": 0.00,
    "shippingHandlingWithDiscountLocalized": 0.00,
    "giftChargeLocalized": 0.00,
    "giftWrapCostLocalized": 0.00,
    "surchargeLocalized": 0.00,
    "totalLocalized": 0.00,
    "subtotalLocalizedFormatted": "$0.00",
    "subtotalDiscountLocalizedFormatted": "$0.00",
    "subtotalWithDiscountLocalizedFormatted": "$0.00",
    "taxLocalizedFormatted": "$0.00",
    "taxableSubtotalLocalizedFormatted": "$0.00",
    "taxableSubtotalDiscountLocalizedFormatted": "$0.00",
    "taxableSubtotalWithDiscountLocalizedFormatted": "$0.00",
    "shippingHandlingLocalizedFormatted": "$0.00",
    "shippingHandlingDiscountLocalizedFormatted": "$0.00",
    "shippingHandlingWithDiscountLocalizedFormatted": "$0.00",
    "giftChargeLocalizedFormatted": "$0.00",
    "giftWrapCostLocalizedFormatted": "$0.00",
    "surchargeLocalizedFormatted": "$0.00",
    "totalLocalizedFormatted": "$0.00",
    "baseCurrencyCode": "USD"
};
if (display_cart) {
    display_cart();
}

...