-
-
Save bekarice/2cc60423043a243c090e to your computer and use it in GitHub Desktop.
Filter WC price display
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
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