Changing Strings – Buy Once or Subscribe for WooCommerce Subscriptions

In the dynamic world of e-commerce, having the right tools to optimize your website’s functionality is crucial. One such tool that brings valuable features to the table is the “Buy Once or Subscribe for WooCommerce Subscriptions” plugin. This plugin empowers online retailers to offer their customers the option to purchase products either as one-time buys or through subscription, accompanied by enticing discounts.

Despite the plugin’s native support and available assistance, there might be instances where default text strings need customization. Our journey led us to implement tailored changes through the use of filters, ensuring a seamless integration of desired modifications.

Original plugin support URL 

Here are a few customizations that you may need to change these default strings or text in the plugin.

The plugin support does provide some help, but in our case it did not work. We were missing the “%value” for the discount after the custom string we added.

So we create our own “filter”

The first one is here

// change text in choose frequency options
add_filter('bos4w_and_save_up_to_text', function($text, $discount) {
$text = 'Subscribe & Save';
$text .= ' ' . sprintf('%s%%', $discount);
return $text;
}, 10, 2); 

this one changes the string/text here

This snippet allowed us to craft a more appealing message, displaying “Subscribe & Save” alongside the corresponding discount percentage. By integrating this customization, you can ensure that your subscription options resonate better with your audience, potentially boosting customer engagement.

 

The second “filter” is

// change text in price display
function custom_bos4w_subscription_text_display($the_subscribe_text) {
// Get the maximum discount value
global $product;
$product_plans = $product->get_meta('_bos4w_saved_subs', true);
$max_discount = 0;

foreach ($product_plans as $plan) {
if ($plan['subscription_discount'] > $max_discount) {
$max_discount = $plan['subscription_discount'];
}
}

// Modify the text based on the maximum discount
if ($max_discount > 0) {
$the_subscribe_text = sprintf('or Subscribe & Save %s', $max_discount . '%');
} else {
$the_subscribe_text = 'Subscribe';
}

return $the_subscribe_text;
}

add_filter('bos4w_subscription_text_display', 'custom_bos4w_subscription_text_display');

 

This changes the string/text in “product price”

 

Enjoy.

You may also like…

How to use LinkedIn for B2B Digital Marketing

How to use LinkedIn for B2B Digital Marketing

Basically, B2B (business-to-business) marketing has to do with the tactics of selling the products and/or services of an organization to another organization. It differs distinctly from business-to-customer transactions because it is based on more logical and...