Community Forums 

Main Content

View cart count and subtotals

    Jul 24 2017 17:18:22

    #1

    Heiress

    Join date : 2010-09-27      Posts : 7

    I used the view cart with forms and it is working great. But, I want to know what can be added to that so the cart count and subtotals are displayed in the view cart button?



    Jul 24 2017 17:50:00

    #2

    GT

    Join date : 2008-09-18      Posts : 3202

    Have you used my view cart script?

    If you have, the details of what can be shown....

    http://www.malsforms.com/display-cart.html

    // comment out any lines you don't need in the 'display cart contents' area.
    // a comment out is two forward slashes as at the start of this line of text.
    // for example, to comment out voucher use:
    // if (thisName == "vch"){
    // document.write("<tr><td>Vouchers:</td><td style=\"align:right\">" + "$" + thisVal + "</td></tr>");
    // }
    if (thisName == "qty"){
    document.write("<tr><td>Items:</td><td style=\"align:right\">" + Math.floor(thisVal) + "</td></tr>");
    }
    // if (thisName == "sub"){
    // document.write("<tr><td>Subtotal:</td><td style=\"align:right\">" + "" + thisVal + "</td></tr>");
    // }
    // if (thisName == "shp"){
    // document.write("<tr><td>Shipping:</td><td style=\"align:right\">" + "" + thisVal + "</td></tr>");
    // }
    // if (thisName == "dis"){
    // document.write("<tr><td>Discounts:</td><td style=\"align:right\">" + "" + thisVal + "</td></tr>");
    // }
    // if (thisName == "vch"){
    // document.write("<tr><td>Vouchers:</td><td style=\"align:right\">" + "" + thisVal + "</td></tr>");
    // }
    // if (thisName == "tax"){
    // document.write("<tr><td>Tax:</td><td style=\"align:right\">" + "" + thisVal + "</td></tr>");
    // }
    if (thisName == "tot"){
    document.write("<tr><td>Total:</td><td style=\"align:right\">" + "" + thisVal + "</td></tr>");
    }
    }

    Having trouble with a form or need one building?
    Fast turnaround, but I do charge :)

    Mal's Forms / Scripts and the syntax are here.




    Jul 25 2017 03:08:20

    #3

    Heiress

    Join date : 2010-09-27      Posts : 7

    Thank you GT,
    I would like to use your view cart script, but as this is new to me and I am using Weebly site building, I don't know where to put it. I tried to put it in the header where I put script for the view cart. But, it moved all of the pages info to the right. So, I am not sure how to add it to the website. Advice needed on where to add your script.



    Jul 27 2017 08:42:38

    #4

    GT

    Join date : 2008-09-18      Posts : 3202

    place it in the head area

    Having trouble with a form or need one building?
    Fast turnaround, but I do charge :)

    Mal's Forms / Scripts and the syntax are here.




    Aug 03 2017 03:59:29

    #5

    Heiress

    Join date : 2010-09-27      Posts : 7

    Any advice would be greatly appreciated on this.

    I added this view care script to the header, (with my info) and everything is working, but the totals are showing up in the address url, following the website address.

    like the example below: (not a link)
    http://mysite.com/product-page.html?qty=1.00&sub=15.95&shp=3.25&dis=0.00&vch=0.00&tax=0.00&tot=19.20&unt=0&sd=

    Here's the script I used:

    <div style="position: fixed; top: 5px; left: 5px;">
    <form method="post" name="myForm" action="http://ww12.aitsafe.com/cf/review.cfm"; onsubmit="document.myForm.elements[0].value=window.location;">
    <input name="return" value="" type="hidden">
    <input name="product" value="" type="hidden">
    <input name="price" value="" type="hidden">
    <input name="qty" value="" type="hidden">
    <input name="userid" value="123456" type="hidden">
    <input src=" https://bagcart.png?1500494509"; title="View Bag" alt="View Bag" width="41" type="image" height="41">
    </form>
    </div>



    Aug 03 2017 10:52:32

    #6

    GT

    Join date : 2008-09-18      Posts : 3202

    Yes that is correct, they should do.. That is what the script reads and then displays.

    By the way, what you have shown us is a form not a script.

    Having trouble with a form or need one building?
    Fast turnaround, but I do charge :)

    Mal's Forms / Scripts and the syntax are here.




    Aug 10 2017 21:39:36

    #7

    Heiress

    Join date : 2010-09-27      Posts : 7

    Okay, I just can't get it figured out. Can somebody please help me by giving me the script that I can use with an image to show the cart quantity similar to this: Bag (0)



    Aug 11 2017 11:13:54

    #8

    GT

    Join date : 2008-09-18      Posts : 3202

    You already have it, you just need it to say Bag and then use brackets around the qty.

    Using this script... http://www.malsforms.com/display-cart-new.html

    Change the lines below...

    if (thisName == "qty"){
    document.write("<tr><td>Items:</td><td style=\"align:right\">" + Math.floor(thisVal) + "</td></tr>");

    To...

    if (thisName == "qty"){
    document.write("<tr><td>Bag</td><td style=\"align:right\">(" + Math.floor(thisVal) + ")</td></tr>");

    Having trouble with a form or need one building?
    Fast turnaround, but I do charge :)

    Mal's Forms / Scripts and the syntax are here.




    Aug 14 2017 18:04:36

    #9

    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>



    Aug 15 2017 20:10:06

    #10

    GT

    Join date : 2008-09-18      Posts : 3202

    Publish your page so we can see all of it...

    Having trouble with a form or need one building?
    Fast turnaround, but I do charge :)

    Mal's Forms / Scripts and the syntax are here.