Cookie Issues

UltraCartShoppingCartID

The getCartInstance method (or ultraCart.init() for v2.0+) call will read/write a cookie named UltraCartShoppingCartID on your domain. This cookie will contain the cart ID that is used to fetch the cart when they reload the page. Great care must be taken with this cookie. Without it, your checkout will not work correctly.

Common Problems

No cookie is set

It's important that the customer have cookies turned on for this checkout API to work. In today's world of web 2.0 websites cookies are mandatory to have turned on for most websites to function properly. After a successful initializing, if document.cookie doesn't contain UltraCartShoppingCartID, it's time to inform the customer that there is a cookie problem.

Cart items disappear going from one page to another

This is common when the checkout moves between urls, usually from www.mystore.com to secure.mystore.com.

The Problem:
The UltraCartShoppingCartID cookie is not transferring between the two sites. It is the critical component for matching a web browser to a cart session stored on the server.
It is being set for a domain of ‘www.mystore.com’, and so it is not available on the checkout page of ‘secure.mystore.com’.
(Also, one might be http and the other is https.)

Now, if you open your console and type ‘document.cookie’, you’ll see that both pages have the cookie, but they are of different values. When the browser goes to the checkout page, the checkout finds no cookie and so created a new cart id.

Possible Solutions:
1. Expand the cookie domain. The checkout api will see the cookie for the server, so it will probably have a domain of 'www.mystore.com’. Take the cart id and reset it to a wider domain cookie.
The code for that would look something like this (execute this code before changing the location to the checkout page).
document.cookie = 'UltraCartShoppingCartID=' + ultraCart.getCart().cartId + ';domain=.mystore.com;path=/;';

2. Pass the session id as a parameter (version 2.0+ syntax below).
location.href = checkoutPage + '?cartid=' + ultraCart.getCart().cartId;

and then on your checkout page, before calling init, you could grab the parameter and then set the cookie.
Solution #1 is cleaner.
Solution #2 exists in case you somehow are unable to get the cookie scope widened.