Created
November 11, 2014 22:53
-
-
Save growdev/967ad18e4bde62cdc190 to your computer and use it in GitHub Desktop.
Add text to the Price based on conditional in WooCommerce
This file contains hidden or 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 | |
add_filter( 'woocommerce_get_price_html', 'growdev_custom_price_message', 30, 2 ); | |
/** | |
* Add string to | |
* | |
* @param $price HTML string | |
* @param $product WC_Product object | |
* @return string | |
*/ | |
function growdev_custom_price_message( $price, $product ) { | |
//error_log( "price: " . $price ); | |
//error_log( "product: " . get_class($product) ); | |
/* | |
[11-Nov-2014 16:42:23 UTC] price: <span class="amount">$20.00</span> | |
[11-Nov-2014 16:42:23 UTC] product: WC_Product_Simple | |
*/ | |
if ( ! is_admin() ) { | |
$s = 59; | |
if ( (int) $product->get_regular_price() >= $s ) { | |
$free_shipping_text = ' <h4>FREE SHIPPING!</h4>'; | |
return $price . $free_shipping_text; | |
} | |
} | |
return $price; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment