Author Topic: Shipment Methods with Min - Max weight issue  (Read 2537 times)

nerfmarius

  • 3rd party VirtueMart Developer
  • Beginner
  • *
  • Posts: 14
Shipment Methods with Min - Max weight issue
« 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?

AH

  • Global Moderator
  • Sr. Member
  • *
  • Posts: 3510
  • VirtueMart Version: 3.8.9
Re: Shipment Methods with Min - Max weight issue
« Reply #1 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;
   }
Regards
A

Joomla 3.9.27
php 7.4

nerfmarius

  • 3rd party VirtueMart Developer
  • Beginner
  • *
  • Posts: 14
Re: Shipment Methods with Min - Max weight issue
« Reply #2 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?

nerfmarius

  • 3rd party VirtueMart Developer
  • Beginner
  • *
  • Posts: 14
Re: Shipment Methods with Min - Max weight issue
« Reply #3 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.

AH

  • Global Moderator
  • Sr. Member
  • *
  • Posts: 3510
  • VirtueMart Version: 3.8.9
Re: Shipment Methods with Min - Max weight issue
« Reply #4 on: July 12, 2013, 13:37:01 pm »
with the 100 g weight what does the debug show as being submitted to the calculation
Regards
A

Joomla 3.9.27
php 7.4

nerfmarius

  • 3rd party VirtueMart Developer
  • Beginner
  • *
  • Posts: 14
Re: Shipment Methods with Min - Max weight issue
« Reply #5 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

glassblowerrobin

  • Beginner
  • *
  • Posts: 2
  • Skype Name: robinschellenberg
Re: Shipment Methods with Min - Max weight issue
« Reply #6 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?

Maxim Pishnyak

  • Global Moderator
  • Sr. Member
  • *
  • Posts: 2656
Re: Shipment Methods with Min - Max weight issue
« Reply #7 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
You can support Community by voting for Project on the JED
https://extensions.joomla.org/extension/virtuemart/#reviews
Join us at
https://twitter.com/virtuemart

glassblowerrobin

  • Beginner
  • *
  • Posts: 2
  • Skype Name: robinschellenberg
Re: Shipment Methods with Min - Max weight issue
« Reply #8 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!

Maxim Pishnyak

  • Global Moderator
  • Sr. Member
  • *
  • Posts: 2656
Re: Shipment Methods with Min - Max weight issue
« Reply #9 on: September 17, 2013, 10:05:27 am »
You're welcome!
You can support Community by voting for Project on the JED
https://extensions.joomla.org/extension/virtuemart/#reviews
Join us at
https://twitter.com/virtuemart

maspegren

  • Beginner
  • *
  • Posts: 11
Re: Shipment Methods with Min - Max weight issue
« Reply #10 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.

jenkinhill

  • UK Web Developer & Consultant
  • Global Moderator
  • Super Hero
  • *
  • Posts: 28337
  • Always on vacation
    • Jenkin Hill Internet
Re: Shipment Methods with Min - Max weight issue
« Reply #11 on: November 01, 2013, 17:48:48 pm »
Try 0.01 for highest weight
Kelvyn

Jenkin Hill Internet,
Lowestoft, Suffolk, UK

Unsolicited PMs/emails will be ignored.

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

Currently using VirtueMart  4.0.2 10661 on Joomla 3.10.9 PHP 7.4.29