I need to add a suffix text to the price of a woocommerce product while on WooCommerce cart.
Based on How to add suffix text to price in WooCommerce cart and checkout page? answer, so I'm trying to adapt that code to recognize product categories.
I am also using has_product_categories()
custom conditional function from this answer.
Here is my code:
add_filter( 'woocommerce_cart_item_price', 'kd_custom_price_message' );
add_filter( 'woocommerce_cart_item_subtotal', 'kd_custom_price_message' );
add_filter( 'woocommerce_cart_subtotal', 'kd_custom_price_message' );
add_filter( 'woocommerce_cart_total', 'kd_custom_price_message' );
function kd_custom_price_message( $price ) {
if( is_cart() && has_product_categories( '46' ) ){
$afterPriceSymbol = ' Monthly';
return $price . $afterPriceSymbol;
} else {
return $price;
}
}
Sadly I keep getting the following error:
Fatal error: Uncaught ArgumentCountError: Too few arguments to function has_product_categories()
I haven't been able to either combine the two (as in including the suffix one here) or adapt this one to the suffix text one.
Any clue what I'm missing?