Skip to content

Instantly share code, notes, and snippets.

@jessepearson
Last active November 22, 2016 19:15
Show Gist options
  • Select an option

  • Save jessepearson/43bfe62d080eeb7663ca9de13eaedb95 to your computer and use it in GitHub Desktop.

Select an option

Save jessepearson/43bfe62d080eeb7663ca9de13eaedb95 to your computer and use it in GitHub Desktop.
Function filters the price of products looking for "Free!" and replaces it with "$0.00"
<?php // copy this line only if needed, usually it's not needed
/**
* Function filters the price of products looking for "Free!" and replaces it with "$0.00"
*
* @param string $price The price being passed
* @param object $product The product we're looking at
* @return string The filtered price
*/
function lets_replace_free_with_zeros( $price, $product ) {
$price = str_ireplace( 'Free!', '$0.00', $price );
return $price;
}
add_filter( 'woocommerce_get_price_html', 'lets_replace_free_with_zeros', 100, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment