Jump to content
thirty bees forum
  • 0

Bug in order weight calculation


30knees

Question

I have an order consisting of 10 x 1kg of Product A, so the total weight should be 10kg, but in the order class it's given as 100kg.

I noticed this because the DHL shipping module I used wanted to calculate with 100g instead of with 10kg. I contacted the module developer and they checked and said it's a bug in thirty bees, because the order class says 100kg and that's where the module takes the weight from.

How can I help find where the issue is? Note: It was only one order out of many, so if it's a tricky issue it might not be worthwhile digging too deep to find where the bug is.

Edited by 30knees
Link to comment
Share on other sites

8 answers to this question

Recommended Posts

  • 0

Looks correct to me: 

https://github.com/thirtybees/thirtybees/blob/1.0.x/classes/order/Order.php

 

public function getTotalWeight()


{

$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue(

(new DbQuery())

->select('SUM(`product_weight` * `product_quantity`)')

->from('order_detail')

->where('`id_order` = '.(int) $this->id)

);



return (float) $result;

}

 

Link to comment
Share on other sites

  • 0

Thanks, @musicmaster!

Some additional information: It's with regard to variants/combinations. My main product has a weight of 0 and the variant has an additional weight of 1kg per unit.

I checked the tables (albeit after having corrected the weight in the DHL module) and I think we've found the culprit:

tb_product: It's correct, 0 for the main product.

tb_product_attribute: It's correct, 1kg.

tb_cart_product: Mine doesn't have weight.

tb_order_detail: It's correct, 10kg.

tb_orders: 139! (total_products_wt)

Where does the total_products_wt come from?

Link to comment
Share on other sites

  • 0

total_products_wt: wt=with tax; So that is not relevant.

The function that you mentioned before gets things from the order_detail table.

However, I have my questions about your order_detail value. I checked it in my shop and I saw the weight for one product in that field. Not the total weight for the number of products that was ordered. 

I don't have time to dive deeper into this. But I suspect this could be the problem.

 

  • Like 1
Link to comment
Share on other sites

  • 0

@datakick found and fixed the bug in 20 minutes. Thanks! I highly recommend his services: https://store.getdatakick.com/en/services He's fixed many buggy modules I've purchased elsewhere where the module developers couldn't or wouldn't provide support.

I contacted the folks at @Common-Services offering them datakick's patch, but they tried to sell me their support instead and then ultimately declined the patch. 

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...