VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: thefbi on February 05, 2012, 15:11:43 PM

Title: Remove quantity box for one product
Post by: thefbi on February 05, 2012, 15:11:43 PM
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.
Title: Re: Remove quantity box for one product
Post by: PRO on February 05, 2012, 17:22:08 PM
why dont you create a separate product layout for the product.

?

Title: Re: Remove quantity box for one product
Post by: thefbi on February 05, 2012, 18:45:10 PM
I dont undurstand your question ???
Title: Re: Remove quantity box for one product
Post by: PRO on February 06, 2012, 13:41:21 PM
create a NEW product details template that does not have the quantity box
Title: Re: Remove quantity box for one product
Post by: thefbi on February 06, 2012, 13:43:40 PM
OK,
but how can i do that ?
And how assign it to just this product ?
Regards.
Title: Re: Remove quantity box for one product
Post by: jenkinhill on February 06, 2012, 21:22:24 PM
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. 
Title: Re: Remove quantity box for one product
Post by: thefbi on February 07, 2012, 18:42:56 PM
OK,
great, it work fine, thanks for the tip !
Title: Re: Remove quantity box for one product
Post by: Lockerbie on May 29, 2012, 19:46:00 PM
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)