News:

Looking for documentation? Take a look on our wiki

Main Menu

Issue with wrong weight calculation

Started by artfener, October 12, 2014, 20:15:05 PM

Previous topic - Next topic

artfener

I have an issue regarding a live site, it's about weight calculation.
If you try to put this product in the cart (q.ty=1):
http://www.gambasafety.com/linea-vita/prodotti/ancoraggi/ancoraggio-round-d-detail.html

And then try to add 1 or more items, when you will update cart the shipment method "TNT TRACO" will display a wrong weight (this product weight is 4 kg per unit), so advanced shipping rates formules will not be able to calculate the right shipping price. The weight appears to be multiplied by itself, ie: for 5 items it seems to calculate (5*5)*4=100kg instead of 5*4=20kg. If you buy 6, the weight is (6*6)*4=144kg, etc.

Software version is
vm2 rules shipping v4.2
VirtueMart 2.6.10
Joomla! 2.5.26

Can someone please help me?  :)
Daniele Comello

GJC Web Design

This certainly isn't normal behaviour - the weights are calculated in vmpsplugin.php if the rules shipping uses getOrderWeight() function

foreach ($cart->products as $product) {
            $weight[$to_weight_unit] += (ShopFunctions::convertWeightUnit ($product->product_weight, $product->product_weight_uom, $to_weight_unit) * $product->quantity);
         }
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

artfener

You're absolutely right, please check the code from my vmpsplugin.php file:

   protected function getOrderWeight (VirtueMartCart $cart, $to_weight_unit) {

      static $weight = array();
      if(!isset($weight[$to_weight_unit])) $weight[$to_weight_unit] = 0.0;
      if(count($cart->products)>0 and empty($weight[$to_weight_unit])){

         foreach ($cart->products as $product) {
            $weight[$to_weight_unit] += (ShopFunctions::convertWeightUnit ($product->product_weight, $product->product_weight_uom, $to_weight_unit) * $product->quantity);
         }
      }
      return $weight[$to_weight_unit];
   }

Best regards

GJC Web Design

but u need to check

1. is the rules plugin using the function getOrderWeight ()

2. if not what and why the calc is inaccurate - you can find your way around the files so ech out some vars to see where it goes wrong
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

artfener

Thanks for your answer but I'm not very skilled to understand it...  :'(

Best regards
Daniele