Skip to content

Instantly share code, notes, and snippets.

@alemarengo
Forked from growdev/gist:967ad18e4bde62cdc190
Last active August 29, 2015 14:09
Show Gist options
  • Save alemarengo/ff92a5fcaa1c8775ed27 to your computer and use it in GitHub Desktop.
Save alemarengo/ff92a5fcaa1c8775ed27 to your computer and use it in GitHub Desktop.
<?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">&#36;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;
}
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