I'm using this code to add text below the price of my products
function cw_change_product_price_display( $price ) {
$price .= ' <span class="unidad">por unidad</span>';
return $price;
}
add_filter( 'woocommerce_get_price_html', 'cw_change_product_price_display' );
add_filter( 'woocommerce_cart_item_price', 'cw_change_product_price_display' );
But I need to display the following text: Price per meter is: and this formula:
$product->get_price()/$product->get_length() . get_woocommerce_currency_symbol();
Product price divided product length, can't get it to work without causing a error in the site.
Also, Is there any way to make this code apply to only certain products? As there are many that are sold per unit