2

Maybe something is amiss with my Theme - but when I go into Wishlist and choose "add to cart" next to the item in the wishlist, nothing happens. No error or anything like that. You just click it and nothing happens.

Is this a form-key issue? Add to cart works everywhere else on the site it is just from the wishlist that this does not work. Also the "Add all to cart" function in the Wishlist works perfectly.

Thanks!

add to cart not working
(source: premierlightbulbs.com)

12
  • have you tried "add all to cart" button to check if that works?
    – MagExt
    Commented Jan 12, 2015 at 21:01
  • Yep that works perfect - adds all products to the cart. Commented Jan 12, 2015 at 21:03
  • seems javascript of "add to cart" button is either missing or failing due to some error. Can you check in firebug console to see if there is any error?
    – MagExt
    Commented Jan 12, 2015 at 21:07
  • It says "> Uncaught ReferenceError: addWItemToCart is not defined (index) : 245" Commented Jan 12, 2015 at 21:09
  • Your javascript function "addWItemToCart" is missing in that page which is responsible to add item from wishlist to cart.
    – MagExt
    Commented Jan 12, 2015 at 21:25

3 Answers 3

2

You need to add form key on wishlist add to cart form

<?php echo $this->getBlockHtml('formkey');?>
1
  • So I add that somewhere on app/design/frontend/base/default/template/wishlist/view.phtml?? Thanks. Commented Jan 13, 2015 at 15:18
1

Turns out my theme MobileShoppe does not even look at view.phtml in app/design/frontend/base/default/template/wishlist. So I had to add the javascript from view.phtml into cart.html in the wishlist template folder of my theme... and now it adds the items to the cart as it should. Thanks to everyone who helped provide solutions.

0

Add the following code into the javascript section of app/design/frontend/[yourtheme]/[yourtheme]/template/wishlist/view.phtml

    function addWItemToCart(itemId) {
    var url = '<?php echo $this->getItemAddToCartUrl('%item%') ?>';
    url = url.gsub('%item%', itemId);
    var form = $('wishlist-view-form');
    if (form) {
        var input = form['qty[' + itemId + ']'];
        if (input) {
            var separator = (url.indexOf('?') >= 0) ? '&' : '?';
            url += separator + input.name + '=' + encodeURIComponent(input.value);
        }
    }
    setLocation(url);
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.