Created
March 10, 2021 05:57
-
-
Save KeylorCR/f4fd4fbc85f706fb833895daf4054475 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* 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']; | |
unset($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