VirtueMart Forum

VirtueMart 2 + 3 + 4 => Administration & Configuration => Topic started by: Patrick on November 10, 2011, 20:17:15 PM

Title: How do I hide the product quantity selection?
Post by: Patrick on November 10, 2011, 20:17:15 PM
VM 2.0 and Joomla 1.7
I only want customers selecting 1 item at once.
So Hiding the quantity box is mandatory.

Thanks Patrick
Title: Re: How do I hide the product quantity selection?
Post by: PRO on November 10, 2011, 21:00:40 PM
remove


                  <?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" 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">
                     <input type="button" class="quantity-controls quantity-plus" />
                     <input type="button" class="quantity-controls quantity-minus" />
                  </span>
                  <?php // Display the quantity box END ?>




http://forum.virtuemart.net/index.php?topic=92756.0
http://forum.virtuemart.net/index.php?topic=90935.0
Title: Re: How do I hide the product quantity selection?
Post by: Patrick on November 11, 2011, 21:29:13 PM
I found it in the default.php, deleted it, worked like a charm..

Thanks
Title: Re: How do I hide the product quantity selection?
Post by: PRO on November 11, 2011, 22:21:50 PM
you need to do a layout override OR it will get overwritten when you update
Title: Re: How do I hide the product quantity selection?
Post by: Patrick on November 14, 2011, 00:22:02 AM
After removing quantity box, products not adding to the cart.
Seems the quantity some how goes to Zero after removing, undefined error in the next box.
put i back temporarily, untill I find a solution.

Title: Re: How do I hide the product quantity selection?
Post by: PRO on November 14, 2011, 13:21:08 PM
add this to the add to cart form. TYPE hidden

<input type="text" class="quantity-input" name="quantity[]" value="1" />

Title: Re: How do I hide the product quantity selection?
Post by: valkas on April 11, 2012, 19:09:16 PM
Hi guys! Could you be little bet specific what is the name files you are talking about and location. Thanks in advance
Title: Re: How do I hide the product quantity selection?
Post by: PRO on April 11, 2012, 19:17:25 PM
Quote from: valkas on April 11, 2012, 19:09:16 PM
Hi guys! Could you be little bet specific what is the name files you are talking about and location. Thanks in advance



default_addtocart.php

http://forum.virtuemart.net/index.php?topic=98505.0
Title: Re: How do I hide the product quantity selection?
Post by: valkas on April 11, 2012, 19:44:14 PM
Thanks again!

after remove lines i've got error
Parse error: syntax error, unexpected '}' in /home/mysite/public_html/components/com_virtuemart/views/productdetails/tmpl/default_addtocart.php on line 72

any advice?
Title: Re: How do I hide the product quantity selection?
Post by: valkas on April 11, 2012, 19:50:53 PM
I deleted line 72 and everything looks good until i press "add to cart" and then i got - "Please enter a valid quantity for this item."
I need one item by default
WOW! Looks like i do something stupid
Title: Re: How do I hide the product quantity selection?
Post by: PRO on April 11, 2012, 22:01:57 PM
Quote from: BanquetTables.pro on November 14, 2011, 13:21:08 PM
add this to the add to cart form. TYPE hidden

<input type="text" class="quantity-input" name="quantity[]" value="1" />




^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Title: Re: How do I hide the product quantity selection?
Post by: bob@robertclinton.com on March 17, 2015, 13:47:12 PM
This is a great tutorial.  Thank you.

In addition, I am looking for a way to set it as "off" by default but toggle "on" for certain products.

I created a URL based version, but that won't work for category pages:
<?php 
$url 'http://' $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
  
?>

  <?php // Display the quantity box ?>
<?php if (strpos($url,'gpa') !== false) : ?>
<div>
<label for="quantity<?php echo $product->virtuemart_product_id;?>" class="quantity_box"><?php echo JText::_('COM_VIRTUEMART_CART_QUANTITY');?>
<input type="text" class="quantity-input" name="quantity[]" value="1" />
</div>
<!-- Display the quantity box END -->
<?php else : ?>
<?php // Removed quantity box ?>
<input type="hidden" class="quantity-input js-recalculate" name="quantity[]" value="1" />
<?php // Removed quantity box END ?>
<?php endif; ?>