Magento 1.8 – Add to Cart URL Not Adding Product for Guest

magento-1.8

My add to cart buttons on a home page widget are not adding product to the cart for users who are not logged in. The javascript call includes the form key and product info:

<button type="button" title="Add to Cart" class="button btn-cart" onclick="setLocation('http://www.zero-bars.com/checkout/cart/add/uenc/aHR0cDovL3d3dy56ZXJvLWJhcnMuY29tLw,,/product/109576/form_key/21vvM0yFWxRdBJoF/')">
                                <i class="icon-bag"></i>
                            </button>

.phtml file:

<button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')">
                                <i class="icon-bag"></i>
                            </button>

The strange thing is it works fine on development server and if I am logged in. Is there a setting in config I am forgetting?

Best Answer

Replaced $this->getAddToCartURL($_product) with Mage::helper('checkout/cart')->getAddUrl($_product) and now it is working fine.

Related Topic