0

we are currently trying to get our drupal commerce 2 attaching a certain shipping method based on the weight of the order. It is pretty simple (at least I thought so): if the order is below 20kg, it is one rate, above a second rate.

Here is what I did:

  • enabled commerce shipping module and physical fields
  • added a custom physical weight field field_prod_gewicht to the default product type (the only one we have)
  • marked the default product variation as shippable
  • filled the individual products with their weights accordingly
  • created two shipping methods with different prices, only restricted by Shippment Weight

So far so good - on the shipping page I see indeed only the lower rate shipping method, but if I add more weight to the order, the higher rate shipping method never appears.

My suspicion is, that the weight is not calculated at all, or that there is some kind of implicit convention I did not follow.

Anybody has an idea, how to solve or debug this?

Thx a lot!

1
  • I noticed, that weight is a dedicated field of the cart api, further strengthening my suspicion, that it is baed on some convention.
    – Andreas
    Mar 25 at 15:31
0

In the end it was ideed as expected a convention: If you enable the commerce shipping module a system level weight field will be added automatically to the Product Variation Entity, not the product.

This weight field is the only field, used for order weight calculations and other custom fields are ignored. All in all very logical ;)

If you want to use the weight in templates, it can be done via {{ product.variation_weight }}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.