News:

Looking for documentation? Take a look on our wiki

Main Menu

Remove quantity box for one product

Started by thefbi, February 05, 2012, 15:11:43 PM

Previous topic - Next topic

thefbi

Hello,
i have VM 2.0.1d and Joomla 2.5.1.
I want to remove the quantity box for just one product. I have seen this post : http://forum.virtuemart.net/index.php?topic=95926.msg315173#msg315173, but my problem is to make it for just one product.
I make a product with possibilities to buy more than one in a package and have promotion for 2 or 3 products in the same time. So i have make customables fields for this. But i dont want the possibilitie to put more quantity of products and block the number to 1 in the configuration is not a good way.
The url to this product is : http://www.energie-sante.ch/le-centre/produits/consommables/papaye-fermentee-anti-age-immuni-stimulant-detail
Regards, Frédéric.

PRO

why dont you create a separate product layout for the product.

?


thefbi


PRO

create a NEW product details template that does not have the quantity box

thefbi

OK,
but how can i do that ?
And how assign it to just this product ?
Regards.

jenkinhill

#5
This is easy.

Open a copy of the file joomla_root/components/com_virtuemart/views/productdetails/tmpl/default.php in a good text editor, notepad would do.

Find the code:

<?php // Display the quantity box ?>
<!-- <label for="quantity<?php echo $this->product->virtuemart_product_id;?>" class="quantity_box"><?php echo JText::_('COM_VIRTUEMART_CART_QUANTITY'); ?>: </label> -->
<span class="quantity-box">
<input type="text" class="quantity-input js-recalculate" name="quantity[]" value="<?php if(isset($this->product->min_order_level) && (int) $this->product->min_order_level 0){echo $this->product->min_order_level;} else{ echo '1'; } ?>" />
</span>
<span class="quantity-controls js-recalculate">
<input type="button" class="quantity-controls quantity-plus" />
<input type="button" class="quantity-controls quantity-minus" />
</span>
<?php // Display the quantity box END ?>


Replace with:

<?php // Removed quantity box ?>
<input type="hidden" class="quantity-input js-recalculate" name="quantity[]" value="1" />
<?php // Removed quantity box END ?>


In this the quantity to be added to the cart is set to one.

Save the file as (eg)  nobutton.php

Upload to your Joomla template html directory to create an override ( http://forum.virtuemart.net/index.php?topic=90935.0 )

eg for Beez_20 template in J2.5.1 the file would go into /joomla_root/templates/beez_20/html/com_virtuemart/productdetails/nobutton.php

At this point log into Joomla admin, open the VirtueMart component & go to the relevant product(s) details page. There you will see the option "Product Details Page". Click in the box next to that where in the files listed you should see "nobutton". Select that, and then for that product there will be no quantity button shown in the FE. 
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

thefbi

OK,
great, it work fine, thanks for the tip !

Lockerbie

Hello Jenkinhill,

I know this thread is a bit old, but still, this could be what I'm looking for.
Instead of removing the quantity box, would it be possible to put a quantity box for adding/subtracting 6 products at a time in a page override for some products? If so, how can I adjust the code for this quantity box?

(J! 2.5.4 - VM 2.0.6)