Help setting up Drupal Commerce shipping rules

pkcho's picture

I'm trying to set up flat rate shipping rules for Drupal Commerce.

Basically, for 1-3 items ordered the shipping price is $xx, for 4-7 items ordered the shipping price is $yy, etc... When I attempt to order 5 products, it shows me the correct flat rate option selected, but in the shipping costs the flat rate is multiplied by 5, so when it should be $5, it shows $25 for the shipping costs. The shipping rate is supposed to apply to the entire quantity, not each individual item.

Obviously, I set the conditions elements incorrectly, but I can't seem to use any other type of data selector besides: commerce-order. Every other option gives me the error:

The integrity check failed with the following error message: "Data selector commerce-order:commerce-order-total: for parameter commerce_order is invalid."

Can someone give me some guidance on this?

Thank you very much.

Comments

I can't speak to your entire

carn1x's picture

I can't speak to your entire problem, however the error you are getting: "Data selector commerce-order:commerce-order-total: for parameter commerce_order is invalid." is because, when you select:

  • "commerce-order:commerce-order-total:"

You may miss the next value available which is:

  • "commerce-order:commerce-order-total:amount"

It's easy to miss this from the Direct Input drop down, as it is usually only a single row, and I have missed it myself many times. Hope this helps.

Interpretation and path to get there

Nora McDougall's picture

Pardon my clarification, but for the folks who are new at this.

Drupal 7.19
Dashboard -> Store -> Configuration -> Shipping

If you have shipping rules started, choose Configure Component from the particular rule.

There are boxes for Conditions and Actions. In a translation to programming-speak. Conditions are if - else, except that a Rule only relates to an if. If the if fails, I suppose it goes to the next rule. Actions are what's inside the curly braces.

The interface is very confusing. With straight programming, we would have a series of tests with actions based on the result of each test. This seems to have all the tests at the top and all the actions at the bottom, which makes absolutely no sense.

I welcome corrections to any errors or omissions.

This sounds like you have the

ajsleigh's picture

This sounds like you have the "Rate type" option on the Rules Action set to a "product..." option instead of "order" therefore it is multiplying the amount by the number of products on the order.

Thank you for helping me. I

pkcho's picture

Thank you for helping me. I really appreciate the quick reply and advice!

carn1x, no matter what I put into that field except (commerce-order), I always get the "Data selector commerce-order:commerce-order-total: for parameter commerce_order is invalid." I have no clue how to use the data selector for that field???

Regardless, I looked for what ajsleigh suggested (I initially could not find that setting). When I finally found it under my "Edit reaction 'Flat rule'" > Actions > "Enable shipping method: Flat rate" > Rate Type

I changed it. Crossed my fingers. Updated my carts items and nothing. The suspicious thing was that no matter what amount of product I put in the cart, the shipping amount would not change. I cleared the cache. I refreshed my browser. I finally decided to log out as admin and attempt this as an anonymous user. When I tested this as anonymous, the shipping costs appeared to be working right. I logged back in and YES! It was working! I don't know why it didn't react correctly and why logging out helped, but if stays working, I'm a happy camper! : )

Thank you very much!

Event?

ñull's picture

Signal, would be interesting to know what Event is triggering your action. Then I would also like to know if you need to do something special to make the shipping visible at check-out?

Data comparison

iris_hbo's picture

I had the same error, then I selected Data comparison, when adding a condition. This screencast helped: http://commerceguys.com/blog/advanced-commerce-shipping-configuration-fr...

Trying to set rules that apply to the whole order

Nora McDougall's picture

The situation you mention is an important logic problem. Instead of a shipping rule applying to the next item in the list, it deals with groups of products. I have a similar situation in that if there is only one product and it is from a specific Product Type, it can ship in the smallest USPS flat rate box and therefore should have a specific shipping price based on the flat rate box.

The problem lies in how to set up a rule for only this one situation, which will move to other rules if that is not the case. This would be so easy in code if - then. But, the client needs to be able to change the shipping rules in the Dashboard; so, we work through the muddle of menus and forms.

Join the thread

ñull's picture

Nora: I would join this thread, where somebody is requesting inclusion of Flat rate boxes in the USPS module. I think that is the best solution to your problem, not fiddling with shipping rules. If USPS has that way of shipping then it should be included in the module.

Part of a bigger picture

Nora McDougall's picture

Thanks for your comment! I will check out that thread.

Actually, the small, flat-rate, shipping box is a very small part of a much larger picture.

If(Order contains up to X Quantity of Product A)
Use small flat rate box
If(Order contains up to Y Quantity of Product A)
Use different flat rate box
If(Order contains only Product B)
Use a multiple large flat rate boxes, based on weight
If(Order contains 1 of Product X and 1 of Product)
Use particular flat rate box

USPS can't determine which flat rate box to use because some of the products take up a lot of space.

And the list goes on ... Most clients would settle for a simple flat rate that would cover most situations. These folks like everything very, very complicated!

So, I have the shipping rules so far, set to do the small flat rate box, but if that product exists at all, it still picks up the small flat rate box. If there is another product involved, I don't want it to pick up the small flat rate box.

That's what I'm trying to figure out. It would be a lot easier in code, but I need to set it in the Dashboard where I can show my client how to change the quantities if they decide to use different packing materials!

LA Drupal (Los Angeles Drupal)

Group events

Add to calendar

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: