Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
There can be a need to set the default flat rate service, as a user hint/shortcut.
Patch attached in comment adds this feature.
Comment | File | Size | Author |
---|---|---|---|
#1 | commerce_flat_rate-1612702-1_default-service.patch | 5.26 KB | kotnik |
Comments
Comment #1
kotnik CreditAttribution: kotnik commentedPatch attached.
Comment #2
kotnik CreditAttribution: kotnik commentedIn order for this to work, patch in #1612706: Add support for default shipping service must be applied as well.
Comment #3
Simon Georges CreditAttribution: Simon Georges commentedWouldn'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?
Comment #4
fagoalso see slightly related #1892264: Allow flat rate services to be exported using Features
Comment #5
JennySmith CreditAttribution: JennySmith commentedI 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:
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)
Comment #6
rszrama CreditAttribution: rszrama commentedI 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.
Comment #9
rszrama CreditAttribution: rszrama commentedAlrighty, 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!