I need to add a suffix text to the price of a woocommerce product from a specific category while on WooCommerce cart.
Here is my code:
add_filter( 'woocommerce_cart_item_price', 'filter_woocommerce_cart_item_price', 10, 3 );
add_filter( 'woocommerce_cart_item_subtotal', 'filter_woocommerce_cart_item_price', 10, 3 );
function filter_woocommerce_cart_item_price( $wc, $cart_item, $cart_item_key ) {
if(!in_array('67',$cart_item['data']->get_category_ids()))
{
return $wc;
}
else{
return $wc . ' Monthly';
}
};
The problem is it only works on simple products. Doesn't seem to affect the prices of variable products (I tested on 3 different sites).
Any idea what I'm missing?