VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: capewellmj on May 07, 2014, 21:10:17 PM

Title: Default weight and LWH is not defaulting when adding new products
Post by: capewellmj on May 07, 2014, 21:10:17 PM
Hello

Not a big deal I don't think . In the Virtuemart configuration we have Default Weight Unit = Pounds and Default LWH Unit = Foot.

However when we add new products it no longer defaults to pounds and feet. It defaults to Killogrammes and Metres.

Any help would be appreciated

Thanks :-)

Martin

Title: Re: Default weight and LWH is not defaulting when adding new products
Post by: yorair on June 17, 2014, 13:56:38 PM
have the same problem but with Centimeters. new products are defaulted to Meters.
Title: Re: Default weight and LWH is not defaulting when adding new products
Post by: Milbo on June 20, 2014, 09:41:27 AM
in the last version? I thought I solved that.
Title: Re: Default weight and LWH is not defaulting when adding new products
Post by: testingaja on August 13, 2014, 18:35:42 PM
VirtueMart 2.6.6  still has this problem... any solutions ?
Title: Re: Default weight and LWH is not defaulting when adding new products
Post by: testingaja on August 13, 2014, 21:49:18 PM
found the solutions... hope it will be fix in the next version...

file: administrator\components\com_virtuemart\views\product\view.html.php

search for this row --> if(!empty($product->product_weight_uom))

replace all if else with this one:

            if(!empty($product->product_weight_uom))
            {   // or !$task=='add'
               $product_weight_uom = $product->product_weight_uom;
               $product_unit = $product->product_unit;

               if(!empty($product->product_lwh_uom))
               {
                  $product_lwh_uom = $product->product_lwh_uom;
               }
               else
               {
                  $product_lwh_uom = VmConfig::get('lwh_unit_default');
               }
            }
            else if(!empty($product_parent))
            {
               $product_weight_uom = $product_parent->product_weight_uom;
               $product_unit = $product_parent->product_unit;

               if(!empty($product_parent->product_lwh_uom))
               {
                  $product_lwh_uom = $product_parent->product_lwh_uom;
               }
               else
               {
                  $product_lwh_uom = VmConfig::get('lwh_unit_default');
               }
            }
            else
            {
               $product_weight_uom = VmConfig::get('weight_unit_default');
               $product_unit = VmConfig::get('weight_unit_default');
               $product_lwh_uom = VmConfig::get('lwh_unit_default');
            }
Title: Re: Default weight and LWH is not defaulting when adding new products
Post by: Milbo on August 14, 2014, 02:23:44 AM
?
This?
Quote
if(!empty($product->product_weight_uom)){   // or !$task=='add'
               $product_weight_uom = $product->product_weight_uom;
               $product_unit = $product->product_unit;
               $product_lwh_uom = $product->product_lwh_uom;
            } else if(!empty($product_parent)){
               $product_weight_uom = $product_parent->product_weight_uom;
               $product_unit = $product_parent->product_unit;
               $product_lwh_uom = $product_parent->product_lwh_uom;
            } else {
               $product_weight_uom = VmConfig::get('weight_unit_default');
               $product_unit = VmConfig::get('weight_unit_default');
               $product_lwh_uom= VmConfig::get('lwh_unit_default');
            }
Title: Re: Default weight and LWH is not defaulting when adding new products
Post by: testingaja on August 14, 2014, 18:00:56 PM
Quote from: Milbo on August 14, 2014, 02:23:44 AM
?
This?
Quote
if(!empty($product->product_weight_uom)){   // or !$task=='add'
               $product_weight_uom = $product->product_weight_uom;
               $product_unit = $product->product_unit;
               $product_lwh_uom = $product->product_lwh_uom;
            } else if(!empty($product_parent)){
               $product_weight_uom = $product_parent->product_weight_uom;
               $product_unit = $product_parent->product_unit;
               $product_lwh_uom = $product_parent->product_lwh_uom;
            } else {
               $product_weight_uom = VmConfig::get('weight_unit_default');
               $product_unit = VmConfig::get('weight_unit_default');
               $product_lwh_uom= VmConfig::get('lwh_unit_default');
            }

yes... that section.... :)
Title: Re: Default weight and LWH is not defaulting when adding new products
Post by: Milbo on August 15, 2014, 10:42:18 AM
What about this solution?


if(!empty($product->product_weight_uom)){
$product_weight_uom = $product->product_weight_uom;
} else if(!empty($product_parent)){
$product_weight_uom = $product_parent->product_weight_uom;
} else {
$product_weight_uom = VmConfig::get('weight_unit_default');
}

if(!empty($product->product_lwh_uom)){
$product_lwh_uom = $product->product_lwh_uom;
} else if(!empty($product_parent)){
$product_lwh_uom = $product_parent->product_lwh_uom;
} else {
$product_lwh_uom = VmConfig::get('lwh_unit_default');
}

if(!empty($product->product_unit)){
$product_unit = $product->product_unit;
} else if(!empty($product_parent)){
$product_unit = $product_parent->product_unit;
} else {
$product_unit = VmConfig::get('product_unit_default','KG');
}
Title: Re: Default weight and LWH is not defaulting when adding new products
Post by: testingaja on August 15, 2014, 23:19:22 PM
Quote from: Milbo on August 15, 2014, 10:42:18 AM
What about this solution?


if(!empty($product->product_weight_uom)){
$product_weight_uom = $product->product_weight_uom;
} else if(!empty($product_parent)){
$product_weight_uom = $product_parent->product_weight_uom;
} else {
$product_weight_uom = VmConfig::get('weight_unit_default');
}

if(!empty($product->product_lwh_uom)){
$product_lwh_uom = $product->product_lwh_uom;
} else if(!empty($product_parent)){
$product_lwh_uom = $product_parent->product_lwh_uom;
} else {
$product_lwh_uom = VmConfig::get('lwh_unit_default');
}

if(!empty($product->product_unit)){
$product_unit = $product->product_unit;
} else if(!empty($product_parent)){
$product_unit = $product_parent->product_unit;
} else {
$product_unit = VmConfig::get('product_unit_default','KG');
}


nope... it didn't work for this situation: Create New Product...

In Virtuemart Configurations -> ShopFront, I set Default LWH Unit  to Centimeters. But in Create New Product, it shows Metres...

thx in advance....
Title: Re: Default weight and LWH is not defaulting when adding new products
Post by: Milbo on August 16, 2014, 04:03:01 AM
just try the new version, there is another line missing, setting the parent to false if there is no parent (id =0)
Title: Re: Default weight and LWH is not defaulting when adding new products
Post by: testingaja on August 16, 2014, 10:49:38 AM
Quote from: Milbo on August 16, 2014, 04:03:01 AM
just try the new version, there is another line missing, setting the parent to false if there is no parent (id =0)

ok... i'll try it... thx... :)