Customize the Thank you message with WooCommerce Subscriptions

Using WooCommerce Subscriptions you get a “Thank you” message after purchasing a subscription product which says:

Your subscription will be activated when payment clears. View the status of your subscription in your account.

Do you know that you can change this text to the that best matches your style/site?

To do so, open the file functions.php located in wp-content/themes/your-theme-name/ and add this code at the end of it:


/**
* Change the subscription thank you message after purchase
*
* @param int $order_id
* @return string
*/
function custom_subscription_thank_you( $order_id ){
if( WC_Subscriptions_Order::order_contains_subscription( $order_id ) ) {
$thank_you_message = sprintf( __( '%sThank you for purchasign our subscription! Visit %syour account%s page to know its status.%s', 'woocommerce-subscriptions' ), '<p>', '<a href="' . get_permalink( wc_get_page_id( 'myaccount' ) ) . '">', '</a>','</p>' );
return $thank_you_message;
}
}
add_filter( 'woocommerce_subscriptions_thank_you_message', 'custom_subscription_thank_you');

view raw

functions.php

hosted with ❤ by GitHub


More Posts That You Might Like…


9 responses to “Customize the Thank you message with WooCommerce Subscriptions”

  1. Thanks

    It worked great.

  2. Hi,

    Tried to add this to my functions.php file, right at the bottom – however this was the result after I copied the code to the file – the page said:

    Parse error: syntax error, unexpected end of file in /home//public_html//wp-content/themes/***/functions.php on line 963

    ( * = hidden from public)

    Please advise on solution.

    [I have latest WP & WooSubscription 2.0.5]

    Regards.

  3. Rather than inserting code, is there a plugin for this?

    Please advise.

  4. FOUND SOLUTION :

    wp-content/plugins/Subscriptionsv2.0.5/includes/class-wc-subscriptions-order.php

    Press Command/Control F on your keyboard and search : ‘Your subscription’ – and you’re able to rename :

    ‘Your subscription will be activated when payment clears. View the status of your subscription in your account’.

  5. flo_itvolcano Avatar

    simi, that’s not a sollution because it’ll be overwritten on next plugin update.

    the code above (besides a typo) has an error. it is missing ; at the end of add_filter( ‘woocommerce_subscriptions_thank_you_message’, ‘custom_subscription_thank_you’)

    So it should be add_filter( ‘woocommerce_subscriptions_thank_you_message’, ‘custom_subscription_thank_you’); instead

  6. Hey Nicola,

    Great blog, I’ve actually landed on your site a few times now with my searches and have used a few of your scripts already, however this one doesnt seem to be working for me. Initially, it was simply throwing me an error, so I added the semi-colon at the very end and cleared the error, however now it has simply removed the default message (“Your subscription will be activated when payment clears. View the status of your subscription in your account.”) altogether.

    I would really like to resolve this if you have any ideas for me. Thanks in advance!

  7. This code just needs a simicolon at the end, thats the only problem. The line:

    add_filter( ‘woocommerce_subscriptions_thank_you_message’, ‘custom_subscription_thank_you’)

    Should be:

    add_filter( ‘woocommerce_subscriptions_thank_you_message’, ‘custom_subscription_thank_you’);

    1. Hey Drew,
      Thanks! I fixed the snippet!

  8. Thanks. A note that this function has now deprecated. Need to replace ‘WC_Subscriptions_Order::order_contains_subscription( $order_id )’ with:

    wcs_order_contains_subscription( $order_id )

Leave a Reply

Categories

Newsletter

Receive new articles from this blog directly in your inbox!

No spam guaranteed!

Blog at WordPress.com.

%d bloggers like this: