WooCommerce Subscriptions - Changing the wording/removing subscription terms (eg /month)

Viewed 238

I found this older post: How to change the "/ month" on a woocommerce subscription product page

''' 
add_filter('woocommerce_subscriptions_product_price_string_inclusions', 
'remove_subscription_inclusions', 10, 2);
function remove_subscription_inclusions( $include, $product ) {
$include['subscription_length'] = '';
return $include;
}
'''

That code works great for the product pages, but it doesn't remove the "/month" ('term' I guess would be the correct term) in the cart/checkout pages.

Does anyone have any idea how to apply the same thing as in the other post the cart/checkout pages as well?

1 Answers
// Line items pricing
add_filter( 'woocommerce_subscriptions_product_price_string', 'wc_subscriptions_product_price_string', 10, 3 );
function wc_subscriptions_product_price_string( $price_string, $product, $args ) {
    if ( is_cart() || ( is_checkout() && ! is_wc_endpoint_url() ) ) {
        return $args['price'];
    }
    return $price_string;
}

// Total line items
add_filter( 'woocommerce_subscription_price_string', 'wc_subscription_recurring_price_string', 10, 2 );
function wc_subscription_recurring_price_string( $subscription_string, $subscription_details ) {
    if ( is_cart() || ( is_checkout() && ! is_wc_endpoint_url() ) ) {
        $recurring_amount = $subscription_details['recurring_amount'];
        
        if( is_numeric( $recurring_amount ) ) {
            return strip_tags( wc_price($recurring_amount) );
        }
        else {
            return $recurring_amount;
        }
    }
    return $subscription_string;
}
Related