Skip to content

Instantly share code, notes, and snippets.

@bekarice
Last active January 4, 2016 00:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bekarice/2cc60423043a243c090e to your computer and use it in GitHub Desktop.
Save bekarice/2cc60423043a243c090e to your computer and use it in GitHub Desktop.
Filter WC price display
function sv_change_product_html( $price_html, $product ) {
if ( 337 === $product->id ) {
$price_html = '<span class="amount">$15.00 per kg</span>';
}
return $price_html;
}
add_filter( 'woocommerce_get_price_html', 'sv_change_product_html', 10, 2 );
function sv_change_product_price_cart( $price, $cart_item, $cart_item_key ) {
if ( 337 === $cart_item['product_id'] ) {
$price = '$15.00 per kg<br>(7-8 skewers per kg)';
}
return $price;
}
add_filter( 'woocommerce_cart_item_price', 'sv_change_product_price_cart', 10, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment