Versions Compared

Key

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

...

Code Block
themeDJango
languagehtml/xml
linenumberstrue
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script>

  var cart = {
        merchantId: 'DEMO',
        shoppingCartId: '12345'
  };

  function unifyCookies() {

    // Perform the JSONP request to unify cookies it (asynchronous by nature)
	// Make sure to change images.ultracart.com to whatever domain UltraCart is providing in the affiliate links generated for the affiliate.
    // images.ultracart.com is the default.
 	jQuery.getJSON('https://images.ultracart.com/cgi-bin/UCCheckoutAPIUnifiedAffiliate?callback=?',
      {
        merchantId: cart.merchantId,
        shoppingCartId: cart.shoppingCartId
      }
    ).done(function(data) {
      if (data.success) {
        // Successful call
        if (data.unified) {
			// Cookies existed and the information was unified properly.
		}
      }
    });
  }

  jQuery(document).ready(function(){
	 // TODO: You will want to load the cart here in your production code before calling unifyCookies.
     // A fake stubbed out cart is shown above for this tutorial.
	 unifyCookies();
  });

</script>