Drupal Commerce 2.x and shipping conditions
This blog post has been re-posted with permission from Studio Present Dev blog.
By default Drupal Commerce 2.x and Commerce Shipping modules come with two nice conditions Limit by total price and Limit by shipment weight. But in some cases these conditions are not good enough for restricting shipping methods.
Let's say that you have different shipping prices for different product weights. Defining these shipping methods with Limit by shipment weight condition cannot be done, because it does not allow defining weight ranges.
To fix this problem I created Limit by shipment weight range condition. You can use it to define shipping methods for a specific weight range. For example if total weight of all products in the cart is between 1 and 10kg you can set one shipping price. For weight range between 10 and 20 kilograms you can define another shipping price and so on.
And this is how the Shipping information checkout pane will look like if total weight sum of all products in the cart is between 1 and 10 kilograms.
The same thing is with Limit by total condition. You cannot use it to define shipping costs based on the total amount of products in the cart for ranges. So, I created another condition called Limit by order price range. You can use it to define shipping prices based on subtotal order price (that is price without any order adjustments) or total order price.
You can download or clone sample module from here: https://github.com/gnikolovski/commerce_gnikolovski