Using woocommerce, I have several categories but would like to add “per person” to the category “cookery classes”.
I have written this function, which works on all products.
I can’t seem to get it to work only on the category.
'/*---------Adds per person to price -------*/
add_filter( 'woocommerce_get_price_html', 'custom_price_html', 500, 2 );
function custom_price_html( $price, $product ) {
if (( int ) is_category( 'Cookery Classes','product_cat', $product->id ) )
$price .='per person';
$price .= '<span class="from"><BR>' . _x('per person', 'price_per_person','woocommerce') . ' </span>';
return $price;
}'
found and installed this plugin:
https://wordpress.org/plugins/woocommerce-jetpack/
Allows you to add custom labels to prices per product catagory