-
-
Save alemarengo/ff92a5fcaa1c8775ed27 to your computer and use it in GitHub Desktop.
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; | |
} |
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
add_filter( 'woocommerce_get_price_html', 'custom_price_message' ); | |
function custom_price_message( $price ) { | |
$sale_price = get_post_meta( get_the_ID(), '_price', true); | |
$s = 59; | |
if ( $sale_price >= $s ) { | |
$ss = '<div class="your-class"><h6>some text</h6></div>'; | |
return $price . $ss; | |
} | |
else if ($sale_price < $s ){ | |
return $price; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment