Unless I have missed how to do it. Would it be possible to add a weight to the Flat Rate Services to control the display order in the Shipping Services pane on the checkout form, when more than one option is available.

For example, I would like 'Express Shipping' to appear below 'Standard Shipping' so that 'Standard Shipping' is the initially selected option when the buyer first visits the page.

Comments

Subscribing - this would be really useful

Ahh, yep. Took me a little bit to remember how I implemented this and realize that it had nothing to do with the Rules execution order. What happens is the Shipping module, when it loads shipping services, assigns a default weight value starting at 0 and incrementing for each service if the service itself doesn't define a weight value. This means the Flat Rate module can allow you to specify a weight value if it wants. Let's do this after the initial beta release so we can properly include an update function that adds the necessary weight column to the commerce_flat_rate_service table.

Subscribing

I had a client that wanted this ability by the end of the week, so I couldn't wait to see if this would eventually get added. I wrote this patch this afternoon, I've not tested the update function in the install file (as I manually updated the database before writing that), but it should be fine, the rest of it has been tested, and seems to work just fine...

You'll need to run update.php after applying the patch.

The patch in #4 works, but I had to apply it manually as the patch didn't apply cleanly for me. I have re-rolled the same patch and applies clean on my machine.

I can't get either of these patches to work after applying manually. I receive the following error:

PDOException: SQLSTATE[HY000]: General error: 1364 Field 'weight' doesn't have a default value: INSERT INTO {commerce_flat_rate_service} (name, title, display_title, description, rules_component, amount, currency_code, data) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7); Array ( [:db_insert_placeholder_0] => ground [:db_insert_placeholder_1] => Ground [:db_insert_placeholder_2] => [:db_insert_placeholder_3] => [:db_insert_placeholder_4] => 1 [:db_insert_placeholder_5] => 999 [:db_insert_placeholder_6] => USD [:db_insert_placeholder_7] => a:0:{} ) in drupal_write_record() (line 6884 of /home3/****/public_html/*****/includes/common.inc).

UPDATE: I should have specified--I get this error when I try to create a new flat rate shipping service.

Status:Active» Needs review

Changing status as there is a patch.

Any chance of this getting committed?

Per #6, this doesn't seem to be working...

Not being able to set the order is a pretty big problem, Ryan could you let us know what is holding the patch up in #5?

Status:Needs review» Needs work

Looks to me from the comments above that this just doesn't work. So I guess just time and a good patch is holding it up. : )

Patch applies cleanly for me and works as advertised ... though digging into it, I seems like a very heavy way to go about it. Could you give an idea on how you'd like it to take shape and I can spend some time on it? Maybe using the rule weights instead?

Issue summary:View changes
StatusFileSize
new9.38 KB

Attached is a patch to finish this out. I am no longer getting the errors and it works for me well so far. The issue with patch #5 was that drupal_write_record needs the schema to match. #5 applied a update to the database but did not add the weight column to the schema itself. I also just added a weight field to the add/edit form so that you can set it there as well.

-Jesse