Sort and Preselect Cheapest Shipping WordPress Function
What it does?
-
Price-based sorting: Reorders shipping rates ascending by cost so the least expensive option appears first.
-
Auto-selects cheapest: Sets the lowest-cost method as the default chosen rate in the session.
-
Scoped to checkout flow: Runs only on the cart and checkout pages; returns rates unchanged elsewhere.
Why it’s useful?
-
Faster decisions, fewer abandons: Customers see the best price immediately, reducing friction.
-
Cleaner presentation: A consistent, logical order prevents confusion—especially with many couriers.
-
Works with your other rules: Plays nicely with your Free-Shipping auto-hide—this sorts whatever rates remain visible.
