Calculating shipping charges by weight
Hi, i'm pretty new to Drupal Commerce. At my internship they asked me to do research about Drupal and webshops. So i started looking into Drupal Commerce.
I need a module, or a way without having to edit code, to calculate a shipping price by weight.
I already added the weight field everywhere I could. And now I'm trying to figure out the Commerce Shipping module, but somehow it won't work.
I added a condition 'entity has field' to get the weight in a variable. But it won't make any calculations. If I add 40 to the price, it will work, but if I try to add weight*3 it won't work.
I alse need a way to have promotions on products. So the original price has to be crossed out and the new one has to be shown, so the buyer knows he is getting a good deal. I've tried Commerce Price Savings Formatter, but it only shows the promotion on the detail page of a product. I tried to edit the rule for this promotion, but since my knowledge about Drupal isn't that big I couldn't get that fixed.
Anyone who can help me?
Next week is my last week at the internship, so I hope I'll find a sollution fast.
Thanks.


Comments
Resources for shipping
Did you already see these screencasts?
You'll find some other resources in those tutorials on http://commerceguys.com that explain various kinds of promotions. Commerce Discount Campaign Feature may give you some ideas about your campaigns.
Watched em all
Yes, I've watched them all. The screencasts helped, but I still couldn't realise what I need.
And my traineeship doesn't want me to use the UPS module. I think this is because they want to be able to choose different shipping services.
For the last 4 days I've read and watched all the information I could find, nothing helped.
The reason I mentioned UPS is
The reason I mentioned UPS is it explains how to use Physical and Commerce Physical.
OK, how about this one :-)
I'll bet you haven't watched this one because I just did it for you :-) This is also saved as a feature module at http://drupal.org/sandbox/rfay/1374058, and the rules are attached as simple text exports if you prefer that.
Thank you
Wow, thanks for the screencast, I didn't expect this.
I'll try out it immediately.
Thanks again ! Much appreciated.
I'll put this in my report, so my traineeship knows there's an amazing support for Drupal Commerce.
Great screencast
Hi thanks for this screencast.
I'm new to rules and this got me started.
I'm trying to calculate the shipping cost per weight with thresholds. i.e
7€ for packages lighter than 2kg
9€ for packages between 2kg and 10kg
And 11€ for packages between 10kg and 30kg.
30kg is the maximum per package, so that if the total order weights 35kg the cost would need to be 20€.
I'm not sure this can be done with rules... Is it possible? I didn't find how to make the conditional calculation based on the weight of the order.
Do you have any tips/ pointers for me?
Kind regards
Did you figure this one out?
Although potentialy everything seems possible, I have a real hard time figuring out this type of conditions.
Rules does not seem to be the best way to achieve such a thing, but what would be an alternative?
My scenario is this:
I have two types of products with each their own properties (weight, dimensions,...). The order can be shipped worldwide. The service we use for this has different rates per weight and also per region( I'm simplifying things here ). We have (roughly) three regions: within the netherlands, within the european union and the rest of the world.(in reality the european union is also subdivided in three different regions, but lets keep it as simple as possible).
I figured what I need to do is setup different 'flat rates' with no actual rate (rate of € 0,-) per region and use conditions using the shipping adres 'country' value to apply the correct service to the order.
So three flatrate services:
In order to know which of these services to apply I created:
This seems to work as expected. When testing, the right service is selected for the shipping address. So far so good.
The next thing to do would be to know the weight of the total order and use that to determine the price category for the current region. There are three categories: up to 2kg, between 2kg and 10kg, and above 10kg.
So I've tried the above hints, but I really can't get it to work together with the defined services or other rules / conditions. I 'm confused about where to use these weight conditions/actions..
So the question is. How to go about this ?
Me too
I'd really like to know how to calculate the shipping cost using weight thresholds/sliding scale.
My feeling is that it's not achievable simply using Rules and needs some kind of custom module... :/
Solution
aha :)
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.
We got error when trying to
We got error when trying to import your rules:
Integrity check for the imported configuratoin failed. Error message: Unknown action component_rules_calculate_shipping_amount_by_weight_of_line_item.
If we reproduce step-by-step your screencast we can't get access to 'line-item-calculated-shipping-cost' (09:14 of your video).
Could you help us to understand our mistake?
Hi rfay. In 7:19, i cannot
Hi rfay.
In 7:19, i cannot add line-item:commerce-product:field-weight:weight.
I create before field-weight.
Why?
It works!
As last option I tried the screencast again with a clean install of Drupal Commerce and it worked!!
But I have found an error in your screencast. When making the rule "Calculate shipping amount by weight of line item" you say in the screencast to add an Integer datatype labeled 'Shipping cost for a line item', but when I check your exported code, I see it's a Decimal number. You probably changed this in the part you cut out. Maybe you should add this to the videos description, to make sure other people notice this.
Now back to promotions. I will try this again myself on my clean Drupal, and make a new topic if I have any trouble. Do you have suggestions if I should use the campaign tutorial or try some module?
Maybe an admin should change this topic title to 'Shipment by weight' since this is the problem discussed.
Edit: just noticed I can do this myself :)
DECIMAL number, not integer. 5:00 into video.
Good catch on the Decimal number! I wasn't seeing the line-item-calculated-shipping-cost value in the data selector (at around 9:10 in the video) There's so many steps in the process. Since I'm new to rules, I was adhering so closely to Randy Fay's (excellent by the way) step by step instructions, I had overlooked this. You saved me an hour of head scratching. Thanks marcmarc!
Yes it works. But what if I
Yes it works. But what if I need to get the sum of the weights of all goods and round it up to 1 kilogram?
I have just done that, apart
I have just done that, apart from the rounding up to 1kg.
Instead of calculating the price it costs to ship each line item and returning it, you simply just return the weight, then where you previously totaled the price, you total the weight. You'll need to add a variable to store it in. Then after the look is complete you can convert the weight into a price.
I currently have an issue, whereby if I set a condition to check for the country...such that I can provide different shipping rates for different countries. So my test case is setting to check the country code is uk and when I select United Kingdom from the list the shipping doesn't turn up as it should. Any ideas...?
[EDIT]
Is there anyway to link a shipping service to a calculation rule?
Total weight
Hi,
I need some help.
If the total weigth of the order is under the limit of 4Kg, I want the total shipping cost to be 5.5€
else the the shipping cost is as the video example.
Please help me...
Type casting
It should be noted here that not all calculation results are Integer. Assigning a Decimal to an Integer component return value is denied. I had to change the return value to Decimal