Discussions

Complex shipping Calculation

Hello,

I have a list of products with weights associated.

I want to add a shipping line on my cart that would be calculated from the total product weight of the cart * specific amount that depends on the weight.

Suppose i have these rules :
If shopping cart total weight is 100g then shipping price is 10 €
If shopping cart total weight is 200g then shipping price is 20 €
If shopping cart total weight is 300g then shipping price is 30 €

In that case the shopping cart will look like this, the total weight is 300g so the shipping price is 30 € :
Product 1 - 100 g - 1 €
Product 2 - 150 g - 2 €
Product 3 - 50 g - 3 €
Shipping 30 €

Can you tell me how to apply this rule and add the shipping line to the cart.

Thanks and sorry for my poor english.

Posted: Nov 10, 2011

Comments

pushka on February 2, 2012

I'd dearly love to know how to do this too, but after watching some (great) tutorial videos on Rules and Drupal Commerce, I think this level of functionality requires some coding.

I see that the Commerce Physical Product module provides an API for getting order total weight, so I'm investigating that. Will post back when/if I make progress.

pushka on February 2, 2012

I made progress :)

Apply the patch here to Commerce Physical Product module : http://drupal.org/node/1344962#comment-5261936

Then you can set up a shipping service for each weight bracket (e.g. 0-1kg, 1-2kg) with corresponding cost.

The patch enables you to easily add conditions to each service (e.g. total weight < 1kg and NOT weight < 2kg).

That's it! Note that the patch only handles kg right now.