Change Woocommerce Subscription Wording

If you are preparing to use the Woocommerce Subscription plugin, you will notice that there is currently no built-in way to change the default wording for the subscriptions. By default wording, I mean the text after the listed monthly amount. For example, “month for 3 months”.

So what if we want to change this wording? Luckily, we can use a custom function to change it. Here are some examples (using a 3-month subscription). Note: If you are putting this function in a theme, it should be in a child theme to prevent it from being overwritten.

This one will change it to “now + 2 more payments”.

add_action( 'init', function() {
    add_filter( 'woocommerce_subscriptions_product_price_string', 'custom_subscription_price_string', 10, 3 );
});

function custom_subscription_price_string( $subscription_string, $product, $include ) {
    if ( $product->is_type( 'subscription' ) ) {
        $price = wc_price( $product->get_price() );

        $billing_period = $product->get_meta( '_subscription_period' );
        $billing_length = (int) $product->get_meta( '_subscription_period_interval' );
        $subscription_length = (int) $product->get_meta( '_subscription_length' );

        if ( $subscription_length > 1 ) {
            $remaining_payments = $subscription_length - 1;
            $subscription_string = "{$price} now + {$remaining_payments} more payment" . ( $remaining_payments > 1 ? 's' : '' );
        } else {
            $subscription_string = "{$price} per {$billing_period}";
        }
    }

    return $subscription_string;
}

In this one I’m flipping it around. The words will be before the price. For example “3 easy payments of”.

add_action( 'init', function() {
    add_filter( 'woocommerce_subscriptions_product_price_string', 'custom_subscription_price_string', 10, 3 );
});

function custom_subscription_price_string( $subscription_string, $product, $include ) {
    if ( $product->is_type( 'subscription' ) ) {
        $price = wc_price( $product->get_price() );

        $billing_period = $product->get_meta( '_subscription_period' );
        $billing_length = (int) $product->get_meta( '_subscription_period_interval' );
        $subscription_length = (int) $product->get_meta( '_subscription_length' );

        if ( $subscription_length > 1 ) {
            $subscription_string = "{$subscription_length} Easy Payment" . ( $subscription_length > 1 ? 's' : '' ) . " of {$price}";
        } else {
            $subscription_string = "{$price} per {$billing_period}";
        }
    }

    return $subscription_string;
}

The possibilities are endless here making this very flexible for whatever you need. If you have any questions, just leave a comment and I’ll try to help as best I can.

Subscribe
Notify of
0 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments