There can be a need to set the default flat rate service, as a user hint/shortcut.

Patch attached in comment adds this feature.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

kotnik’s picture

Status: Active » Needs review
FileSize
5.26 KB

Patch attached.

kotnik’s picture

In order for this to work, patch in #1612706: Add support for default shipping service must be applied as well.

Simon Georges’s picture

Wouldn't #1342270: Add tabledrag support to set flat rate service rate weights be the way to go? Ordering the services should be a way to choose a default, don't you think?

fago’s picture

JennySmith’s picture

I think my issue is related to this one. I think default shipping rates ought to be triggered using default customer profiles rather than setting order or a default shipping option flag.

I'm setting up a single page checkout. I've got two main shipping options:

  • flat rate international (where shipping country != US)
  • flate rate domestic (where shipping country = US)

The default country for shipping address in the customer profiles section is set to US, but the shipping module does not use that value to set its initial shipping rates. Instead of showing the domestic value as expected since the default US is selected, the international flat rate is displayed, I assume because shipping country != US is returning true, which probably means that the code isn't looking at the default values in the profile. Hope this makes sense -- coding isn't my forte'.

Correct shipping rates are displayed once the customer completes the shipping form and triggers shipping module to recalculate (after city, country, state, zip are all entered)

rszrama’s picture

Issue summary: View changes
Status: Needs review » Needs work

I have a need for a default flat rate service as well. Funny to see you in the queue from so long ago, kotnik!

I think we can just implement this as a variable, though, and we can do it without depending on a patch to Commerce Shipping. I'll reuse your form concept, though, and just alter the default value of the shipping service radio buttons element when we don't have a default value in the form state or an existing shipping line item on the order.

  • rszrama committed b93f512 on 7.x-1.x
    Issue #1612702 by rszrama, kotnik: add support for designating or...

  • rszrama committed ff12826 on 7.x-1.x
    Issue #1612702 follow-up by rszrama: only alter the checkout form when...
rszrama’s picture

Status: Needs work » Fixed

Alrighty, the API and form to make a service the default is in, the default can also be unset, and the checkout form gets altered appropriately when a default flat rate service has been set. Huzzah!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.