VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: anant_maks on November 18, 2016, 16:05:47 PM

Title: Remove 'add to cart button' on all view except productdetails
Post by: anant_maks on November 18, 2016, 16:05:47 PM
I have created a custom plugin. I want a buyer should only be able to 'add to cart' using these created fields, only on productdetails view. Until then, no add to cart button should be displayed. I also achieved this using javascript via a system plugin, though I am looking for a more better solution, as removing it via some function like - plgVmOnDisplayProductFEVM3 or something else. As a different templace could have different class for 'addtocart-bar'

I would also like to know is there anyhow we can remove 'quantity-box' and 'quantity-control' only, from 'addtocart-bar'
Title: Re: Remove 'add to cart button' on all view except productdetails
Post by: GJC Web Design on November 18, 2016, 16:51:58 PM
just clone the sublayout and do the change

then call this in the category views
Title: Re: Remove 'add to cart button' on all view except productdetails
Post by: Studio 42 on November 20, 2016, 22:52:07 PM
Check the jinput  "view" value and set $product->orderable to false when this is not "productdetails"
Title: Re: Remove 'add to cart button' on all view except productdetails
Post by: anant_maks on November 21, 2016, 17:28:52 PM
Thanks @studio42, that is what I was looking for. I didn't though it would be that simple. Though there is one more thing, I hope you can suggest something better for it. Whenever $product->orderable is set to false then a new button takes its position for that product, and that is 'choose a variant'. I even didn't need that, on debugging more into $product, I didn't found any parameter that can remove this button too.
Title: Re: Remove 'add to cart button' on all view except productdetails
Post by: Studio 42 on November 21, 2016, 18:33:40 PM
You can overide addtocart button if you prefere using in the same loop
$product->addToCartButton = 'my new button';
if you use $product->addToCartButton = '';
it not work, for empty button use $product->addToCartButton = '<span></span>';
Another solution is to modify the sublayouts/addtocartbtn.php but this is then for all the shop including non orderable in productdetails view..
Title: Re: Remove 'add to cart button' on all view except productdetails
Post by: anant_maks on November 22, 2016, 11:14:12 AM
@Studio42 ok, this worked well. Thanks for all your responses. I wanted to create my own button and I am able to do it now.
Thanks again!
Title: Re: Remove 'add to cart button' on all view except productdetails
Post by: driver_wedge on January 10, 2017, 12:59:13 PM
Quote from: Studio 42 on November 21, 2016, 18:33:40 PM
Another solution is to modify the sublayouts/addtocartbtn.php but this is then for all the shop including non orderable in productdetails view..

Hi guys... if I wanted to achieve the above (have a new button for each product on category page that simply links to product page), which specific strings should I be looking at changing? I could probably work it out after a bit of messing about, but any advice that will save me on added stress would be much appreciated.

Many thanks!!!
Title: Re: Remove 'add to cart button' on all view except productdetails
Post by: Studio 42 on January 10, 2017, 13:38:11 PM
@driver_wedge : if you need ofr the whole shop, then remove addtocart render in the sublayout products.
Title: Re: Remove 'add to cart button' on all view except productdetails
Post by: driver_wedge on January 10, 2017, 13:48:54 PM
Thanks S42. Basically, I want to get rid of 'choose a variant' from the products that have variants, and therefore not orderable....therefore, I think the simplest option is to remove the add to cart button althogher across the site and replace it with a new button which displays 'view product', or something similar. I would prefer customers to visit the product page anyway, rather than add to cart from the category page.

I realise that I can probably get this done by someone more knowledgeable than me for a small fee, but I'd like to have a look and understand how the relevant php code renders in the front end.

Does that make sense?

Thanks again...
Title: Re: Remove 'add to cart button' on all view except productdetails
Post by: aftertaf on January 22, 2017, 22:56:17 PM
maybe my mini (mini) doc on how i did this for me may help a bit too...: http://forum.virtuemart.net/index.php?topic=136472.msg477005#msg477005