R10 issue with adding to cart after adding from More Items

For general questions and discussions specific to the AbleCommerce GOLD ASP.Net shopping cart software.
Post Reply
User avatar
AbleMods
Master Yoda
Master Yoda
Posts: 5170
Joined: Wed Sep 26, 2007 5:47 am
Location: Fort Myers, Florida USA

R10 issue with adding to cart after adding from More Items

Post by AbleMods » Mon Feb 22, 2016 4:21 am

Adding an item from the More Items In Category control bugs the product page's main add-to-cart button when the browser back button is used to return to the product page.

Steps To Reproduce

From the shopper side...
Clear your basket
Find a product that doesn't have variants or choices.
Scroll down and find a product in the 'More Products In Category...' control. This product should have "Add To Cart" button text, not "More Details".
Click the Add-to-Cart button for the product in the More Products In Category... control.
You should now be on the basket page and see the more-products-in-category product you clicked.
Now click the browser back button. You should now be on the product page you were on before.
Click the product page Add-to-Cart button.
You should now be on the basket page again.

But instead of two different products in the basket, you now have a quantity 2 of the more-products-in-category product you added first.

Is there a quick fix to this? I've got a client rather concerned about it as they do a lot of related-product business.
Joe Payne
AbleCommerce Custom Programming and Modules http://www.AbleMods.com/
AbleCommerce Hosting http://www.AbleModsHosting.com/
Precise Fishing and Hunting Time Tables http://www.Solunar.com

User avatar
Katie
AbleCommerce Admin
AbleCommerce Admin
Posts: 2651
Joined: Tue Dec 02, 2003 1:54 am
Contact:

Re: R10 issue with adding to cart after adding from More Items

Post by Katie » Mon Feb 22, 2016 5:06 am

I can reproduce it in Gold R11 as well. It works if I add the main product first. The problem only happens if you add the item from the "Also in..." section, then back to the product itself.

It can be reproduced by using either the "Product Display in Rows" or "Basic Product" display template. You have to make sure the mini-basket is disabled.

I'll report the issue. AC8-3047
Thank you for choosing AbleCommerce!

http://help.ablecommerce.com - product support
http://wiki.ablecommerce.com - developer support

User avatar
AbleMods
Master Yoda
Master Yoda
Posts: 5170
Joined: Wed Sep 26, 2007 5:47 am
Location: Fort Myers, Florida USA

Re: R10 issue with adding to cart after adding from More Items

Post by AbleMods » Mon Feb 22, 2016 5:51 am

Awesome thanks for the quick review Katie!

I don't know about you at 6:06 am, but I sure wasn't awake at 5:21 am :)
Joe Payne
AbleCommerce Custom Programming and Modules http://www.AbleMods.com/
AbleCommerce Hosting http://www.AbleModsHosting.com/
Precise Fishing and Hunting Time Tables http://www.Solunar.com

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: R10 issue with adding to cart after adding from More Items

Post by mazhar » Tue Feb 23, 2016 3:27 am

This seems to be happening due back button, browser cache and how ASP.NET handles post backs in javascript. It seems like it happened to other people too as being discussed here
http://weblog.west-wind.com/posts/2007/ ... ack-Button

The simplest fix in our case should be to clear the special ASP.NET fields called __EVENTTARGET and __EVENTARGUMENT upon JQUERY ready event. Edit Website/ConLib/BuyProductDialog.ascx file and following javascript to it. I used regular expression to narrow the scope of this change to use of Add To Cart Link.

Code: Select all

<script type="text/javascript">
// CLEAR CACHED __EVENTTARGET AND __EVENTARGUMENT VALUES UPON DOM READY
    $(function () {
        var addToCartExp = new RegExp('\\$AddToCart_([0-9]+)$');
        var eventtarget = $('#__EVENTTARGET').val();
        if (addToCartExp.test(eventtarget)) {
            $('#__EVENTTARGET').val('');
            $('#__EVENTARGUMENT').val('');
        }
    });
</script>

User avatar
AbleMods
Master Yoda
Master Yoda
Posts: 5170
Joined: Wed Sep 26, 2007 5:47 am
Location: Fort Myers, Florida USA

Re: R10 issue with adding to cart after adding from More Items

Post by AbleMods » Wed Feb 24, 2016 8:25 am

Wow, what an unusual set of circumstances. Leave it to me to find the really good stuff eh? :)

I'll give your script a try and let you know the results.
Joe Payne
AbleCommerce Custom Programming and Modules http://www.AbleMods.com/
AbleCommerce Hosting http://www.AbleModsHosting.com/
Precise Fishing and Hunting Time Tables http://www.Solunar.com

Post Reply