VirtueMart Forum

VirtueMart 2 + 3 + 4 => Plugins: Payment, Shipment and others => Topic started by: alwinchankong on February 06, 2014, 15:34:35 PM

Title: To select shipment by combination of product weight =0 OR >0.. Need Help!
Post by: alwinchankong on February 06, 2014, 15:34:35 PM
Condition:
To detect shipment if upon checkout if any product's weight in shopping cart is 0 or >0


/administrator/components/com_virtuemart/plugins/vmpsplugin.php

protected function getOrderWeight (VirtueMartCart $cart, $to_weight_unit) {
 
    $i=0;
    $totalweight=array();
static $weight = 0.0;
if(count($cart->products)>0 and empty($weight)){
foreach ($cart->products as $product) {
     
vmdebug('getOrderWeight',$product->product_weight);                 
        $totalweight[$i]=". $weight . ";
       
        if (in_array("0.0", $totalweight)) {
            $weight = 0.0;
        }
       
        else
        {
            $weight += (ShopFunctions::convertWeigthUnit ($product->product_weight, $product->product_weight_uom, $to_weight_unit) * $product->quantity);
        }

}
}
return $weight;
}


But it doesn't work the way as i expected. Please advice.