Author Topic: Remove quantity box for one product  (Read 7716 times)

thefbi

  • Jr. Member
  • **
  • Posts: 178
Remove quantity box for one product
« 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.

PRO

  • Global Moderator
  • Super Hero
  • *
  • Posts: 10420
  • VirtueMart Version: 3+
Re: Remove quantity box for one product
« Reply #1 on: February 05, 2012, 17:22:08 pm »
why dont you create a separate product layout for the product.

?

J3.9+ VM 3.4.2
Slowest Page Speed Score (88) (Category)
Fastest Page Speed Score (94-96) (productdetails)

thefbi

  • Jr. Member
  • **
  • Posts: 178
Re: Remove quantity box for one product
« Reply #2 on: February 05, 2012, 18:45:10 pm »
I dont undurstand your question ???

PRO

  • Global Moderator
  • Super Hero
  • *
  • Posts: 10420
  • VirtueMart Version: 3+
Re: Remove quantity box for one product
« Reply #3 on: February 06, 2012, 13:41:21 pm »
create a NEW product details template that does not have the quantity box
J3.9+ VM 3.4.2
Slowest Page Speed Score (88) (Category)
Fastest Page Speed Score (94-96) (productdetails)

thefbi

  • Jr. Member
  • **
  • Posts: 178
Re: Remove quantity box for one product
« Reply #4 on: February 06, 2012, 13:43:40 pm »
OK,
but how can i do that ?
And how assign it to just this product ?
Regards.

jenkinhill

  • UK Web Developer & Consultant
  • Global Moderator
  • Super Hero
  • *
  • Posts: 27897
  • Always on vacation
    • Jenkin Hill Internet
Re: Remove quantity box for one product
« Reply #5 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:
Code: [Select]
<?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:
Code: [Select]
<?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

Jenkin Hill Internet,
Lowestoft, Suffolk, UK

Unsolicited PMs/emails will be ignored.

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

Currently using VM 3.8.5 10338 on Joomla 3.9.22 PHP 7.4.9

thefbi

  • Jr. Member
  • **
  • Posts: 178
Re: Remove quantity box for one product
« Reply #6 on: February 07, 2012, 18:42:56 pm »
OK,
great, it work fine, thanks for the tip !

Lockerbie

  • Jr. Member
  • **
  • Posts: 102
Re: Remove quantity box for one product
« Reply #7 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)