Skip to content

Instantly share code, notes, and snippets.

@dangoodman
Created September 12, 2018 10:45
Show Gist options
  • Save dangoodman/b3bd3c83682c26eacbb9990ee598f16a to your computer and use it in GitHub Desktop.
Save dangoodman/b3bd3c83682c26eacbb9990ee598f16a to your computer and use it in GitHub Desktop.
WooCommerce: shipping option description
<?php
// Paste everything below this line to your child-theme's functions.php file.
// Transforms
// >> Shipping Option Name (shipping option description): $99
// to
// >> Shipping Option Name: $99<br>
// >> <small>shipping option description</small>
add_filter('woocommerce_cart_shipping_method_full_label', function($label, $method) {
if (($open = strpos($label, '(')) !== false &&
($close = strpos($label, ')', $open+1)) !== false) {
$desc = substr($label, $open+1, $close - $open - 1);
$label = substr_replace($label, '', $open, $close - $open + 1);
$label .= "<br><small>{$desc}</small>";
}
return $label;
}, 10, 2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment