Announcement

Collapse
No announcement yet.

How do I empty the cart when people leave the checkout?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    How do I empty the cart when people leave the checkout?

    This JavaScript function will empty your customer's shopping cart when they click the 'Cancel' button on the checkout. It is useful as sometimes it is confusing for customers if they still have items in their shopping cart, when they think they have cancelled the transaction.

    To begin, place the following JavaScript functions in the <head> area of the overall page layout that is being used in the checkout. You can verify this in the 'Checkout Pages Layout' field in 'Settings | Site Options | Layouts'.

    Add it in just above the closing </head> tag.

    HTML Code:
    <script language="Javascript" type="text/javascript">
    function createCookie(name,value,days) {
    if (days)
    {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
    }
    else var expires = "";
    document.cookie = name+"="+value+expires+"; path=/";
    }
    
    function CancelOrder() {
    if (confirm('This will clear your order and address details completely.\nClick "View Cart" to change your order.\nDo you wish to proceed?') == true)
    {
    createCookie("ACTINIC_CART","",-2);
    createCookie("CART_CONTENT","",-2);
    createCookie("CART_COUNT","",-2);
    createCookie("CART_TOTAL","",-2);
    createCookie("ACTINIC_BUSINESS","",-2);
    createCookie("ACTINIC_REFERRER","",-2);
    window.location.href = 'http://www.YOURSITE.com/RETURN-PAGE';
    }
    }
    </script>
    Replace 'http://www.YOURSITE.com/RETURN-PAGE' with the location of a page you want to take customers to.

    Then go to 'Design | Library | Layouts' and locate the 'Checkout Button' group. Within it, locate 'Checkout Cancel Button' and double-click on it to open it.

    Replace the code in the file with the following:

    HTML Code:
    <input type="button" name="ACTION" value="<actinic:variable encoding="html" name="CancelButton" />" class="input" onclick="CancelOrder();" />
Working...
X