Skip to content

Instantly share code, notes, and snippets.

@dangoodman
Last active October 12, 2018 17:39
Show Gist options
  • Save dangoodman/6ef5ff62edb3a03c9a5cd732b64a29bc to your computer and use it in GitHub Desktop.
Save dangoodman/6ef5ff62edb3a03c9a5cd732b64a29bc to your computer and use it in GitHub Desktop.
Hide free shipping options' labels
<?php
// Paste everything below this line to your theme's functions.php file.
// Hide free shipping options prices.
// Example:
// — Free Shipping: $0.00 => Free Shipping
// — Regular Shipping: $20 => Regular Shipping: $20
add_filter('woocommerce_cart_shipping_method_full_label', function($label, WC_Shipping_Rate $rate) {
if (isset($rate->cost) && (float)$rate->cost === 0.0) {
list($label,) = explode(':', $label, 2);
}
return $label;
}, 99, 2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment