Last active
August 12, 2016 11:27
-
-
Save harishankerr/eb830b271176c1043b9ca861a695f863 to your computer and use it in GitHub Desktop.
Modify the display of free price in cart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 = 'Free'; | |
} | |
return $price_html; | |
} | |
add_filter( 'woocommerce_get_price_html', 'sv_wc_free_cart_price', 10, 2 ); | |
add_filter( 'woocommerce_cart_product_price', 'sv_wc_free_cart_price', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment