0

I've made some basic modification in Magento to create a webshop on were returning/regular customers can order their products. It's some kind of dealership website where the wishlist is used as an inventory/catalog for the customers. I've managed to make some modification so that none of the products on the wishlist are being removed when adding to the cart.

But now i'm stuck with one problem; when a customer creates an order from the wishlist it's sometimes the case that they don't want to order all of their products from the wishlist, example:

Wishlist:

  • Product A, Qty: 2
  • Product B, Qty: 0
  • Product C, Qty: 3
  • Product D, Qty: 0

When using the button 'Add all to cart' I get the following result in cart:

Cart:

  • Product A, Qty: 2
  • Product B, Qty: 1
  • Product C, Qty: 3
  • Product D, Qty: 1

All the products that are added to the cart even the products that are set to 0 in the Wishlist. I tried everything and also tried to modify the classes and functions, but no result. I have to admit that I'm not an hardcore Magento Developer, but know some basic PHP. So I don't ask to people to write complete functions for me, but some little help in the right direction would be great!

Long story short: disable the function of adding products from wishlist to cart when qty is set to 0 in wishlist ;)

Magento CE ver : 1.9.0.1

1 Answer 1

0

That action is handled by Mage_Wishlist_Controller_Abstract class. In there, you will have function allcartAction which adds all wishlist products to the cart. Inside that function, you can see a foreach loop which iterates over wishlist items and set quantities for them and then add them to cart.

You can try re-writing that class method and adding a conditional in there which stops add to cart when qty posted is 0. Not sure, if that's the best way to do this (I'm not a fan of re-writes), but it will get the work done.

2
  • Thank you very much! I solved it thanks to your advice! At least I hope I solved it the correct way.. This is the 'rewrite' i did: if ($qty > 0){ if ($item->addToCart($cart, false)) { $addedItems[] = $item->getProduct(); } } Note: The false in if($item->addToCart($cart, false) is there to prevent from emptying the wishlist. This was implemented by me before modifying the code like i write in this comment.
    – WillCom
    Commented Nov 19, 2015 at 14:13
  • Yeah, looks correct, Just hoping you used the Magento 'rewrite' method instead of directly editing the file !
    – Prateek
    Commented Nov 19, 2015 at 15:11

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.