Community Forums 

Main Content

Re:View cart count and subtotals

    Aug 14 2017 18:04:36

    #1

    Heiress

    Join date : 2010-09-27      Posts : 7

    when I try to use the script below in my html editor my entire page disappears, I change all cart info to match my info, please advise what I am doing wrong.

    <div style="position: fixed; top: 5px; right: 5px; width: 150px; margin: 20px; font-family: tahoma, arial, helvetica, sans-serif; font-size: 10pt; border: 1px solid #FC7216; border-radius: 6px; box-shadow: 0px 2px 0px #FC7216;">
    <script type="text/javascript">
    //<![CDATA[
    // nothing to touch here
    function SetCookie(cookieName,cookieValue,mins){
    var today = new Date();
    var expire = new Date();
    expire.setTime(today.getTime() + 60000*mins);
    document.cookie = cookieName+"="+escape(cookieValue) + ";expires="+expire.toGMTString();
    }
    function ReadCookie(cookieName){
    var theCookie=""+document.cookie;
    var ind=theCookie.indexOf(cookieName);
    if (ind==-1 || cookieName=="") return "";
    var ind1=theCookie.indexOf(';',ind);
    if (ind1==-1) ind1=theCookie.length;
    return unescape(theCookie.substring(ind+cookieName.length+1,ind1));
    }
    var loc = document.location;
    var cookieResult = ReadCookie("gt_mals_total");
    if (loc.search){
    var search = loc.search.slice(1);
    if (search.indexOf("qty") >= 0){
    SetCookie('gt_mals_total',search,30); //30 mins
    }
    }

    function deleteCookie(cookieName) {
    if (document.cookie != document.cookie) {
    index = document.cookie.indexOf(cookieName);
    } else {
    index = -1;
    }
    if (index == -1) {
    document.cookie=cookieName+"=GONEcbEndCookie; expires=Monday, 19-Aug-1996 05:00:00 GMT";
    }
    //document.location.href = document.location.href;
    //to reload without queryString parameters, use the line below instead
    document.location = document.location.href.substring(0,document.location.href.indexOf("?"));
    }

    // end of nothing to touch here

    // adjust the width below to suit your needs
    document.write("<table class=\"total\"\>");
    // end of adjust the width below to suit your needs

    // nothing to touch here
    var cookieResult = ReadCookie("gt_mals_total");
    if (cookieResult == ""){
    document.write("<tr><td colspan=\"2\" style=\"align:center\">Cart empty</td></tr>");
    } else {
    var valsArray = cookieResult.split("&");
    for (i in valsArray){
    var thisValPair = valsArray;
    var thisValArray = thisValPair.split("=");
    var thisName = thisValArray[0];
    var thisVal = thisValArray[1];
    // end of nothing to touch here

    if (thisName == "qty"){
    document.write("<tr><td>Items:</td><td style=\"align:right\">" + Math.floor(thisVal) + "</td></tr>");
    }
    if (thisName == "tot"){
    document.write("<tr><td>Total:</td><td style=\"align:right\">" + "" + thisVal + "</td></tr>");
    // change the above "" symbol to your currency symbol, example "$".
    }
    }
    document.write("<tr><td colspan=\"2\"><a href=\"http://ww12.aitsafe.com/cf/review.cfm?userid=E9120065&return=www.malsforms.com/display-cart-new.html\"_target_ >View Cart/Checkout</a></td></tr>");
    // change the return url to your page url above
    }
    document.write("</table>");
    //]]>

    // Remove any table that you see positioned here, it is created by the script, for example:
    // <table class="total"><tbody><tr><td>Items:</td><td style="align: right;">6</td></tr><tr><td>Total:</td><td style="align: right;">35.94</td></tr><tr><td colspan="2"><a href="http://ww12.aitsafe.com/cf/review.cfm?userid=E9120065&return=www.malsforms.com/display-cart-new.html"; _target_="">View Cart/Checkout</a></td></tr></tbody></table>
    </script><table class="total"><tbody><tr><td style="align:center" colspan="2">Cart empty</td></tr></tbody></table>
    </div>

    </div>