News:

Support the VirtueMart project and become a member

Main Menu

How do I hide the product quantity selection?

Started by Patrick, November 10, 2011, 20:17:15 PM

Previous topic - Next topic

Patrick

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

PRO

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

Patrick

I found it in the default.php, deleted it, worked like a charm..

Thanks

PRO

you need to do a layout override OR it will get overwritten when you update

Patrick

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.


PRO

add this to the add to cart form. TYPE hidden

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


valkas

Hi guys! Could you be little bet specific what is the name files you are talking about and location. Thanks in advance

PRO

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

valkas

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?

valkas

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

PRO

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" />




^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

bob@robertclinton.com

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; ?>