Skip to content

Instantly share code, notes, and snippets.

@bekarice
Created May 31, 2016 22:11
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save bekarice/fea75fecbde280c158398011ffc9f839 to your computer and use it in GitHub Desktop.
Save bekarice/fea75fecbde280c158398011ffc9f839 to your computer and use it in GitHub Desktop.
Modify free price display in cart
<?php // only copy if needed
/**
* Change cart price display for free products
*
* @param string $price_html the price display html
* @param \WC_Product
* @return string - updated pricing html
*/
function sv_wc_free_cart_price( $price_html, $product ) {
if ( 0 === (int) $product->get_price() ) {
$price_html = 'No charge!';
}
return $price_html;
}
add_filter( 'woocommerce_cart_product_price', 'sv_wc_free_cart_price', 10, 2 );
@radumg
Copy link

radumg commented Jun 27, 2016

Hi Beka, many thanks for the snippet, works great for the cart page !
Any idea how/which hook to use in order to do the same for the final checkout page ? Still displays a 0 price.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment