0
votes

I'm using Magento 1.6.2, with quite a bit of customization - including a heavily modified shopping cart template.

I'm having issues when a user clicks the browser's 'back' button, after adding an item to the shopping cart. I'm only able to reproduce this issue using Firefox. Chrome and IE work fine.

Steps to reproduce.

  1. Open a specific product page, click 'add to cart'.
  2. You are forwarded to the shopping cart/preview page.
  3. Use the browsers 'back' button to return to the product view.
  4. The 'Add to cart' button is now completely nonfunctional. On products with custom required options, validation is not run. Really, nothing happens at all.
  5. Return to the product catalog. Locate and return to the same item used previously.
  6. Click 'Add to cart'. Everything works properly - you are redirected to the shopping cart, with an updated QTY.

I have no idea where to begin. Anyone have any ideas?

Production/live site: http://myerstownsheds.com/ 'Request Quote' is actually the 'add to cart' button, we're not selling anything yet.

1
Do you perhaps get a javascript error after hitting the backbutton and returning to te product view page?Leven
This probably is a template problem. You must check with the designer or show us some code to try solve out.Rafael Kassner
thnx, added the site link. I wasn't getting any errors in the firebug console, but I'll check again.chris stamper
Also, I just noticed: adding the jquery source to the page completely disables the button as well (probably a prototype conflict?). Could this be related?chris stamper

1 Answers

1
votes

The problem is that when the button is clicked, it becomes disabled.

This is only an issue in Firefox because firefox doesn't reset the page state when the back button is used, you tend to be returned to the page in the exact state you left it, in this case with the button disabled.

Replicate the same issue in any browser by clicking the add to cart button and then pressing stop. You can't click the button again.

On your page, you have a javascript tag that includes this:

    var productAddToCartForm = new VarienForm('product_addtocart_form');
    productAddToCartForm.submit = function(button, url) {
        if (this.validator.validate()) {
            var form = this.form;
            var oldUrl = form.action;

            if (url) {
               form.action = url;
            }
            var e = null;
            try {
                this.form.submit();
            } catch (e) {
            }
            this.form.action = oldUrl;
            if (e) {
                throw e;
            }

            if (button && button != 'undefined') {
                button.disabled = true;
            }
        }
    }.bind(productAddToCartForm);

By setting the button to "disabled" when clicked, Magento prevents a user from clicking the button multiple times if the page load is slow. If you want to fix this issue you'll need to remove the lines that say:

    if (button && button != 'undefined') {
        button.disabled = true;
    }

But you'll also have to live with the other problem.