VirtueMart Forum

VirtueMart Dev/Coding Central: VM1 (old version) => Development Projects, Modifications, Hacks & Tweaks. VM1.1 => Topic started by: NikolaiM on April 09, 2012, 07:09:17 am

Title: [Hack] VM1.1.8 - Customise Products in Attribute_Drop
Post by: NikolaiM on April 09, 2012, 07:09:17 am

Client wanted products to show up that are sold out in the attribute list but have they greyed out saying - "Sold Out"

This code will also work to show the amount available in stock next to each product

See demo:

You need to have it in VM that "Check Stock" and "Show Products that are Out of Stock" and then edit:


Find: function list_attribute_drop( $product_id, $cls_suffix ) {

add product_in_stock to the query here:

         $q1 = " AND product_in_stock > 0 ";
      $q = "SELECT product_id,product_name, product_in_stock FROM #__{vm}_product WHERE product_parent_id='$product_id' AND product_publish='Y'" ;

Find: // Start row for this child

//Nikolai Show Sold Out Products Disabled
                                $whatstock = $db->f( "product_in_stock" );
                               if ($whatstock == '0') {
                               $disabled = 'disabled="disabled"';
                               $soldout = '- Sold Out';
                               $disabled = '';
                               $soldout = '';
                               //If you want to show the in-stock amount next to each product in the list use this
                               //$soldout = '$whatstock';
Directly below, remove the code that generates the <option> and replace with:

$html .= "<option " . $disabled . " value=\"" . $db->f( "product_id" ) . "\" $selected>" ;

while( $db_item->next_record() ) {

$html .= $soldout;
if( ! $db_sku->is_last_record() )

Title: Re: [Hack] VM1.1.8 - Customise Products in Attribute_Drop
Post by: mimi86uk on October 11, 2012, 17:59:12 pm
This didn't work for me.
I have virtuemart 1.1.5 and I kept getting syntax errors.

My attributes (sizes) look like graphic boxes.
I have different quantities of different sizes (

Do you have any advice?? I dont want to upgrade because then i gotta pay more money for the template to work.  ;)