Change order of shipping methods at checkout
The order your shipping methods appear at checkout follows the order they're listed on Sunshine > Settings > Delivery & Shipping. To rearrange them, drag and drop the methods on that page and save.
If you'd rather control the order in code (for example, to always show Pickup before Flat Rate without touching the admin), filter sunshine_allowed_shipping_methods and reorder the array. Each entry is keyed by instance ID, with the value containing the method's id (flat_rate, free, local, pickup, etc.) and active flag.
add_filter( 'sunshine_allowed_shipping_methods', 'sunshine_reorder_shipping_methods', 999 );
function sunshine_reorder_shipping_methods( $shipping_methods ) {
$pickup = array();
$others = array();
foreach ( $shipping_methods as $instance => $method ) {
if ( $method['id'] === 'pickup' ) {
$pickup[ $instance ] = $method;
} else {
$others[ $instance ] = $method;
}
}
return $pickup + $others;
}
Learn how to add this custom code to your WordPress website
This example moves every Pickup instance to the top of the list, with all other shipping methods following in their original order.
Still need help?
If you have not yet found your answer in the documentation articles, please contact support