Skip to content

Instantly share code, notes, and snippets.

@wsenjer
Forked from frankschrijvers/functions.php
Last active September 23, 2020 11:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wsenjer/a37e5b63fcf504c5eb1c977e9da24bdf to your computer and use it in GitHub Desktop.
Save wsenjer/a37e5b63fcf504c5eb1c977e9da24bdf to your computer and use it in GitHub Desktop.
Hide AUS_PARCEL_EXPRESS
/**
* woocommerce_package_rates is a 2.1+ hook
*/
add_filter( 'woocommerce_package_rates', 'hide_express_post', 10, 2 );
/**
* Hide shipping rates when free shipping is available
*
* @param array $rates Array of rates found for the package
* @param array $package The package array/object being shipped
* @return array of modified rates
*/
function hide_express_post( $rates, $package ) {
// Only modify rates if free_shipping is present
if ( isset( $rates['AUS_PARCEL_EXPRESS'] ) ) {
unset( $rates['AUS_PARCEL_EXPRESS'] );
}
return $rates;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment