VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: anandmahey on October 01, 2019, 12:26:15 PM

Title: <SOLVED>Hide Quantity Box with a Product Details template Override
Post by: anandmahey on October 01, 2019, 12:26:15 PM
Hi, i'd like to be able to hide the quantity box with an override, product specific. I understand thar this can be done with template overrides which are selected from the Virtuemart Admin console.

I've gone through as much as i can, and tried several methods on the forums. The latest being editing addtocartbar.php and adding it to template/html/com_virtuemart/sublayouts and also adding a copy of html/com_virtuemart/productdetails/default.php

I've commented out the lines where quantity box references are, in addtocartbar.php but this causes the quantity box to hide for all products. I need to hide the quantity box for a few products only. Could some please guide me? I've tried adding the edited addtocartbar.php to productdetails folder, and select the override from backend but it breaks the page.

Thank you
Virtuemart Version: 3.6.2 10159
Joomla Version: 3.9.12
Title: Re: Hide Quantity Box with a Product Details template Override
Post by: jenkinhill on October 01, 2019, 15:41:09 PM
You started off in the right way, but you need to have two versions of addtocartbar.php - the normal version which will display the quantity box & controls and an override which won't.  This is done by using an override copy of the productdetails default.php file to call an override sublayout addtocart.php which in turn calls an override sublayout addtocartbar.php

Call the override files something different to the original files - eg add 1 to the end of the file names. Then edit default1.php to call 'addtocart1' instead of'addtocart' and in addtocart1.php call 'addtocartbar1' instead of 'addtocartbar'

Then create a new product category (eg noquant) and on the view settings tab of that category set Product layout to use your default1.php.  Then add all products which are not to show the quantity box to that category - they should still be assigned to their original category. Then test.

If you want to remove the box from the category display as well as product details then you will have to play some more! 

There are of course, other ways to do this.
Title: Re: Hide Quantity Box with a Product Details template Override
Post by: anandmahey on October 03, 2019, 04:37:53 AM
Hi jenkinhill, thank you. Wow this seems complicated, but i'm willing to try :)

And i would like to play some more please  ;D Please do let me know how i can do the same for category display :)
Title: Re: Hide Quantity Box with a Product Details template Override
Post by: anandmahey on October 03, 2019, 09:26:36 AM
It worked!! The products details page worked!!

I'm trying categories display now, i've been trying to follow https://forum.virtuemart.net/index.php?topic=130589.0 but no cigar :( Not sure why. Should i start a new thread for Category display on frontpage? The Category List display, basically where all the products on shown on the frontpage