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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

lodey’s picture

Subscribing - this would be really useful

rszrama’s picture

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.

bander2’s picture

Subscribing

ajaysolutions’s picture

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.

arvinsingla’s picture

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.

dbkern’s picture

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.

Simon Georges’s picture

Status: Active » Needs review

Changing status as there is a patch.

marktheshark’s picture

Any chance of this getting committed?

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

aidanlis’s picture

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?

rszrama’s picture

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. : )

aidanlis’s picture

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?

dobe’s picture

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

rszrama’s picture

Title: Control the display order of the shipping options on the checkout form » Add tabledrag support to set flat rate service rate weights

I forgot we had multiple issues for the same feature and just committed a patch in #1537394: Change Shipping Services Row Weights to add a weight column to flat rate services and related UI components. However, I didn't do anything to override the flat rate service table and provide drag-and-drop functionality, so I'm going to repurpose this issue to focus on just that. It will require a reroll, unfortunately.