News:

Support the VirtueMart project and become a member

Main Menu

<SOLVED>Hide Quantity Box with a Product Details template Override

Started by anandmahey, October 01, 2019, 12:26:15 PM

Previous topic - Next topic

anandmahey

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

jenkinhill

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.
Kelvyn
Lowestoft, Suffolk, UK

Retired from forum life November 2023

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

anandmahey

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 :)

anandmahey

#3
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