VirtueMart Forum

VirtueMart 2 + 3 + 4 => Plugins: Payment, Shipment and others => Topic started by: nerfmarius on July 12, 2013, 10:48:04 AM

Title: Shipment Methods with Min - Max weight issue
Post by: nerfmarius on July 12, 2013, 10:48:04 AM
Hello,

I am unable to select shipment method if it has min weight max weight boundaries set.

http://shops.projects.joomwebsites.com/rcq_new/en/ this is the website, and I to see debug messages for all for now.

Thing is, when you add product to cart and get to the select shipment method part in debug messages you can clearly see that some shipment methods are availible.

However, when you try to select one and save, in debug messages you will see that

vmdebug shipmentmethod Test = FALSE for variable weight = 40000 Reason: is NOT within Range of the condition from 1 to 100

The zeros are added to the actual value on submit, so where I had product with 40 grams it is now 40 000 and therefore shipment method isnt saved.

I am using latest VM. 2.0.22 (this issue was in previous version also) and joomla 2.5.

Could anyone help me please?
Title: Re: Shipment Methods with Min - Max weight issue
Post by: AH on July 12, 2013, 11:16:07 AM
VM is clearly adjusting the weight to KG

What do you have set for the default weight unit in admin > configuration > shopfront ?
Compare this to what you have in the shipment plugin method cofiguration for weight unit

From vmpsplugin.php

/**
    * Get the total weight for the order, based on which the proper shipping rate
    * can be selected.
    *
    * @param object $cart Cart object
    * @return float Total weight for the order
    * @author Oscar van Eijk
    */
   protected function getOrderWeight (VirtueMartCart $cart, $to_weight_unit) {

      static $weight = 0.0;
      if(count($cart->products)>0 and empty($weight)){
         foreach ($cart->products as $product) {
            vmdebug('getOrderWeight',$product->product_weight);
            $weight += (ShopFunctions::convertWeigthUnit ($product->product_weight, $product->product_weight_uom, $to_weight_unit) * $product->quantity);
         }
      }
      return $weight;
   }

This function then converts the weight
From shopfunctions:-
/**
    * Get the total weight for the order, based on which the proper shipping rate
    * can be selected.
    *
    * @param object $cart Cart object
    * @return float Total weight for the order
    * @author Oscar van Eijk
    */
   protected function getOrderWeight (VirtueMartCart $cart, $to_weight_unit) {

      static $weight = 0.0;
      if(count($cart->products)>0 and empty($weight)){
         foreach ($cart->products as $product) {
            vmdebug('getOrderWeight',$product->product_weight);
            $weight += (ShopFunctions::convertWeigthUnit ($product->product_weight, $product->product_weight_uom, $to_weight_unit) * $product->quantity);
         }
      }
      return $weight;
   }
Title: Re: Shipment Methods with Min - Max weight issue
Post by: nerfmarius on July 12, 2013, 12:19:28 PM
Hello,

Thanks for the reply.

In VM Configuration - Shopfront, I have weight unit Grams, same as in shipping method config.
Anyway, why would default weight unit interfere with the one assigned to specific shipping method?

What could I do to solve this issue?
Title: Re: Shipment Methods with Min - Max weight issue
Post by: nerfmarius on July 12, 2013, 12:34:58 PM
It looks like it doesn't take weight unit in to account at all, it only looks at the boundaries, for example I have Shipment method that is for products with weight ranges 0 - 100 grams, and I have a product with weight 20 kg, I can select shipment method for that product, and it only fails after trying to submit.
Title: Re: Shipment Methods with Min - Max weight issue
Post by: AH on July 12, 2013, 13:37:01 PM
with the 100 g weight what does the debug show as being submitted to the calculation
Title: Re: Shipment Methods with Min - Max weight issue
Post by: nerfmarius on July 12, 2013, 13:49:18 PM
Its kind of wierd. Before submitting

vmdebug getOrderWeight Var1:
100.0000

vmdebug shipmentmethod Neregistruotas paštas = TRUE for variable weight = 0.1 Reason: is lower than the set 99

and after submit

vmdebug getOrderWeight Var1:
100.0000
vmdebug shipmentmethod Neregistruotas paštas = FALSE for variable weight = 100 Reason: is over 99

this is the product with 100g weight

http://shops.projects.joomwebsites.com/rcq_new/lt/produktai/auto-modeliai/guoliai/by-size/5x10x4-revolution-bearing-mr105-rsz-detail
Title: Re: Shipment Methods with Min - Max weight issue
Post by: glassblowerrobin on September 16, 2013, 15:52:42 PM
Version 2.0.22c
I also have problems with min and max weight concerning shipment methods.
E.g. a product weighs 120 g. I programmed some shipment methods. What I discover is that only the shipment methods where I don't have any minimum boundary are showing up. For this product I get to chose between: "letter" up to 49 g - "parcel" up to 20 kg - "pick it up yourself" up to 1000 kg. But the option Letter between 50 and 349 g is not showing up.
Now, if I chose to buy various products which together weigh more than 20kg, I still get same three options.

Can somebody help?
Title: Re: Shipment Methods with Min - Max weight issue
Post by: Maxim Pishnyak on September 16, 2013, 16:51:18 PM
Could you provide screen shots of your shipment methods setup? Maybe you couldn't use g, only kg? 349 g = 0.349 kg
Title: Re: Shipment Methods with Min - Max weight issue
Post by: glassblowerrobin on September 16, 2013, 19:14:27 PM
Hi
Now I did change the default weight unit at the shopfront configuration of shop from g to kg. And all the shipment methods from g to kg. And the weight of a test product from g to kg. And indeed. It works!!!  8)

Just took some time to figure out that the gram unit is the problem.

Thank's for help!
Title: Re: Shipment Methods with Min - Max weight issue
Post by: Maxim Pishnyak on September 17, 2013, 10:05:27 AM
You're welcome!
Title: Re: Shipment Methods with Min - Max weight issue
Post by: maspegren on November 01, 2013, 17:08:37 PM
Hello, I'm having a Min-Max weight issue too that is not related to the weight unit. I have LBS set everywhere in Virtuemart. I am using VM 2.0.24 and Joomla 2.5.14. I would like free shipping on my gift cards, but UPS shipping on everything else. I have weights for all products but a weight of zero for my gift cards. I have a UPS module that seems to be working correctly then I set up a standard shipping method for products with: Highest Weight:0, Weight Unit: LBS, Shipment Cost:0. I had to set the two zeros in the database because the module won't keep them in the settings. When I try to purchase a product with a weight, I get UPS options AND free shipping option. Obviously if the max weight is zero, this option shouldn't come up. My debug says:
vmdebug getOrderWeight Var1:
0.0000
vmdebug getOrderWeight Var1:
1.0000
vmdebug shipmentmethod No shipping for Gift Cert. = TRUE for variable weight = 1 Reason: no boundary conditions set

Any ideas? It looks like the highest weight boundary of zero is not getting captured/used.
Title: Re: Shipment Methods with Min - Max weight issue
Post by: jenkinhill on November 01, 2013, 17:48:48 PM
Try 0.01 for highest weight