Announcement

Collapse
No announcement yet.

Add to Cart action hack- redirecting to Categories page

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

  • Add to Cart action hack- redirecting to Categories page

    Any of you Javascript geniuses out there find a way to do this: Allow a shopper to add an item to the cart, but instead of the usual followup action that sends them to quickcart, view cart, or checkout, your store redirects them instead to another product or category page?

    I tried hacking the hard code on listing_0 page, changing the ProductAddtoCart button javascript handler to execute two events (1.adding item to cart and 2.redirecting to a category page). THis isn't working on Firefox or Chrome. Here's my code, if anyone's interested in giving my pointers on a better way to get it done.

    <input type="button" onClick="check_and_add(document.add); window.location='Plans_c_7.html';" name="Add" ID="Add" value="[product_addtocart]" class="btn" onMouseOver="this.className='btn_over'" onMouseOut="this.className='btn'"/>
    IMD Modeling
    Modeling in Medford, Oregon

  • #2
    Originally posted by digitalou View Post
    <input type="button" onClick="check_and_add(document.add); window.location='Plans_c_7.html';" name="Add" ID="Add" value="[product_addtocart]" class="btn" onMouseOver="this.className='btn_over'" onMouseOut="this.className='btn'"/>
    Sorry, don't have a ton of time to try anything too in depth( about to head out the door..lol) You can try this instead:

    <input type="button" onClick="check_and_add(document.add); window.location.replace("http://yourdomain.com/Plans_c_7.html");" name="Add" ID="Add" value="[product_addtocart]" class="btn" onMouseOver="this.className='btn_over'" onMouseOut="this.className='btn'"/>
    TheCartDesigner.com
    Not 3dcart Owned or Operated
    100% Independent 3dcart Expert


    Follow Us on Twitter

    Comment


    • #3
      i would ajax the add to cart part and just do a redirect.

      $.serializeArray() on the form itself and just send it as an ajax post with the default form action. on success() just do window.location(yourlocationhere)

      Comment


      • #4
        Actually theres a way without a hack and without javascript now: http://forums.3dcart.com/announcemen...ry-2014-a.html

        For category pages you could change your add to cart url to something like this: add_cart.asp?quick=1&item_id=[catalogid]&returnurl=[the url you want to go to]

        and for product pages you could add this inside of the add to cart form that gets submitted:

        HTML Code:
        <input type="hidden" name="returnurl" value="[the url you want to go to]">
        I haven't tested these recently but I had them working before we changed our add to cart to an ajax method.
        Michael

        JES Restaurant Equipment

        Comment


        • #5
          Originally posted by jleclair View Post
          i would ajax the add to cart part and just do a redirect.

          $.serializeArray() on the form itself and just send it as an ajax post with the default form action. on success() just do window.location(yourlocationhere)
          I wasn't able to use $.serializeArray() and get it to work. I think it had something to do with the image upload part, and I couldn't find a way around it.

          I had to use "new FormData(document.add)" inside of $.ajax, and fallback to the default action if a browser didn't support it.
          Michael

          JES Restaurant Equipment

          Comment


          • #6
            Originally posted by mtbottens View Post
            Actually theres a way without a hack and without javascript now: http://forums.3dcart.com/announcemen...ry-2014-a.html

            For category pages you could change your add to cart url to something like this: add_cart.asp?quick=1&item_id=[catalogid]&returnurl=[the url you want to go to]

            and for product pages you could add this inside of the add to cart form that gets submitted:

            HTML Code:
            <input type="hidden" name="returnurl" value="[the url you want to go to]">
            I haven't tested these recently but I had them working before we changed our add to cart to an ajax method.
            HOLY OCCAM'S RAZOR BATMAN!!!!!
            Mtbottens, this trick works like a boss.
            IMD Modeling
            Modeling in Medford, Oregon

            Comment

            Working...
            X