VirtueMart Forum

VirtueMart 2 + 3 + 4 => General Questions => Topic started by: pablo.egido on July 05, 2012, 18:51:00 PM

Title: dropdown quantity box missing in vm 2.0.8
Post by: pablo.egido on July 05, 2012, 18:51:00 PM
Hi,
In olds VM i had the option in List Products - display options -> "Drop Down Box Values" in quantity. Now i have the VM 2.0 and I have a problem, I'm trying to find this option but I not find it.
Is possible that is missing?

Anyone could help me? Thanks and regards.
Title: Re: dropdown quantity box missing in vm 2.0.8
Post by: PRO on July 05, 2012, 19:43:19 PM
this is not an option in 2.0 as of right now
Title: Re: dropdown quantity box missing in vm 2.0.8
Post by: pablo.egido on July 05, 2012, 19:55:06 PM
Ok. Thank you very much.
Regards.
Title: Re: dropdown quantity box missing in vm 2.0.8
Post by: pablo.egido on July 05, 2012, 20:36:25 PM
Hi,
I solved my problem writing a litte bit of code:

first, I do a little fudge: i use 3 fields to do it: in product-> product status.
min_order_level - > the minimum value
max_order_level -> the maximul value
low_stock_notification -> the interval (how much I want to increase)

In my case, the interval must be float because I need decimals. Then I change it with phpmyadmin in the database.

second, I go to the file where I list the products and change it. (.\components\com_virtuemart\views\category\tmpl\default.php)

I comment the two original lines. (are more or less in the 310 line)

<span class="quantity-box">
  <?php            
//<input type="text" class="quantity-input" name="quantity[]" value="1" />
//<label></label>

$code = '';
$code = '<select class="inputboxquantity" id="quantity'.$prod_id.'" name="quantity[]">';
$inicial = 0;
$final = 50;
$intervalo = 1;

if ($product->min_order_level > 0){
$inicial = $product->min_order_level;
}
if ($product->max_order_level > 0){
$final = $product->max_order_level;
}
if ($product->low_stock_notification > 0){
$intervalo = $product->low_stock_notification;
}

      for($i=$inicial;$i<$final;$i += $intervalo) {
         $code .= '  <option value="'.$i.'"';
         if ($i == 5) {
            $code .= ' selected="selected"';
         }
         $code .= '>'.$i."</option>\n";
      }
      $code .= "</select>\n";
      echo $code
?>

</span>

and all is working fine. Regards.
Title: Re: dropdown quantity box missing in vm 2.0.8
Post by: pablo.egido on July 05, 2012, 21:29:46 PM
I do it too in: (.\components\com_virtuemart\views\productdetails\tmpl\default_addtocart.php)

the difference is that you must use: $this->product->min_order_level and not $product->min_order_level

$code = '';
$code = '<select class="inputboxquantity" id="quantity'.$prod_id.'" name="quantity[]">';
$inicial = 0;
$final = 50;
$intervalo = 1;

if ($this->product->min_order_level > 0){
$inicial = $this->product->min_order_level;
}
if ($this->product->max_order_level > 0){
$final = $this->product->max_order_level;
}
if ($this->product->low_stock_notification > 0){
$intervalo = $this->product->low_stock_notification;
}

      for($i=$inicial;$i<$final;$i += $intervalo) {
         $code .= '  <option value="'.$i.'"';
         if ($i == $intervalo) {
            $code .= ' selected="selected"';
         }
         $code .= '>'.$i."</option>\n";
      }
      $code .= "</select>\n";
      echo $code;

regards
Title: Re: dropdown quantity box missing in vm 2.0.8
Post by: stavroch on December 05, 2012, 14:35:45 PM
I am using the v. 2.0.14 and I can't find the above instructions that you described.
How can I have drop down box instead of text box in quantity field?