Community Forums 

Main Content

Post to cart without displaying cart page

    Nov 04 2016 19:30:24

    #1

    dwight

    Join date : 2010-05-06      Posts : 18

    A client would like to me to be able to set him up so that when products are added to the cart the page displayed does not change. The Shopping Cart logo will then display the number of items in the cart. Then a 'checkout' button would be available when the customer is finished shopping. (similar to Amazon) Is this possible, and if so, how do I code it?

    UPDATE >> Well, I did some research and found the 'nocart' function. However, that causes a jump to the top of the page, it's actually a quick return rather than staying on the same page. Then I saw a suggestion to use an anchor, but that is just a random place on the page. Is there a way for the page to stay perfectly still while the item is added?



    Nov 05 2016 05:47:09

    #2

    GT

    Join date : 2008-09-18      Posts : 3207

    Are the pages html or php?

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

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




    Nov 05 2016 20:49:45

    #3

    dwight

    Join date : 2010-05-06      Posts : 18

    These pages are all php. you can see one here:

    http://www.american-plasticlumber.com/Furniture/PI-640-Bench.php



    Nov 06 2016 05:33:42

    #4

    GT

    Join date : 2008-09-18      Posts : 3207

    This is an old method, not sure it is modern cross browser or mobile compliant...

    Add this to the submit...

    onclick='var scroll = get_scroll(); alert(scroll.x + "x and " + scroll.y + "y")'

    Add this script into the head area of the page...

    <script type='text/javascript'>
    var get_scroll = function() {
    var x = 0, y = 0;
    if ( typeof( window.pageYOffset ) == 'number' ) {
    y = window.pageYOffset;
    x = window.pageXOffset;
    } else if ( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    y = document.body.scrollTop;
    x = document.body.scrollLeft;
    } else if ( document.documentElement &&
    ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    y = document.documentElement.scrollTop;
    x = document.documentElement.scrollLeft;
    }
    var obj = new Object();
    obj.x = x;
    obj.y = y;
    return obj;
    };
    </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.




    Nov 06 2016 16:26:59

    #5

    dwight

    Join date : 2010-05-06      Posts : 18

    Thanks, GT for your reply. However, I'm sorry to say it didn't work. The shopping cart page still appears. In addition I get a popup on the screen with the coordinates. I recognized the alert part of the code and removed it, but still it takes me to the cart page.

    I may have to stay with things the way they are. The good news is that we are selling very few large items, not lotsa small items, so it may not be a big issue.



    Nov 06 2016 20:19:33

    #6

    GT

    Join date : 2008-09-18      Posts : 3207

    How does it take you to Mals if you are using the nocart syntax???

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

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




    Nov 07 2016 16:55:19

    #7

    dwight

    Join date : 2010-05-06      Posts : 18

    Well fooey, one mistake was mine, I had value=nocart rather than name=nocart. So that takes care of that.

    However, I left the alert on and the X value is always 0 and Y is 798 but it still goes to the top of the page.



    Nov 07 2016 17:39:58

    #8

    GT

    Join date : 2008-09-18      Posts : 3207

    Without seeing the page, we can only guess...

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

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




    Nov 07 2016 18:05:59

    #9

    dwight

    Join date : 2010-05-06      Posts : 18

    GT, Thanks for your time, maybe sometime later I'll look further into the js code. I gotta move on and complete another 90 or so pages. For now, I have the return link going to the index page, just 1 level above that product.

    There is a link a couple of posts above.

    Anyway, I appreciate your time. - Dwight



    Nov 08 2016 05:30:35

    #10

    GT

    Join date : 2008-09-18      Posts : 3207

    Yes I checked the link you gave, it is not using the script, so no wonder that page does not work.

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

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