Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
* Change shipping method priority
* Use array_unshift for the beginnig and array_push onto the end of array
function kmchild_sort_shipping_methods($available_shipping_methods, $package) {
if (isset($available_shipping_methods['wc_pickup_store'])) {
$wc_pickup_store = $available_shipping_methods['wc_pickup_store'];
// array_unshift($available_shipping_methods, $wc_pickup_store); // Prepend element to the beginning of array
array_push($available_shipping_methods, $wc_pickup_store); // Push element onto the end of array
return $available_shipping_methods;
add_filter('woocommerce_package_rates', 'kmchild_sort_shipping_methods', 10, 2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment