Add class to woocommerce checkout body based on filter
I am trying to add a class to a checkout page if the checkout contains a subscription renewal.
Woocommerce provides wcs_cart_contains_renewal()
to check.
I am using this code but obviously missing something as it's not working.
$cart_items = wcs_cart_contains_renewal();
if ( ! empty( $cart_items ) ) {
add_filter( 'body_class','my_body_classes' );
function my_body_classes( $classes ) {
$classes[] = 'renewal-order';
return $classes;
}
}
Any help on how to make this work?
Topic body-class filters Wordpress
Category Web