Buy Once or Subscribe for WooCommerce Subscriptions | Developer Hooks and Filters

Filters for changing strings

↑ Back to top

Filter for editing the text next to the price when a product has a Subscription frequency set

↑ Back to top

Description:

bos4w_subscription_text_display – allows editing of the “or subscribe and save up to” text.

add_filter( 'bos4w_subscription_text_display', function ( $display_text ) {
   // custom code
   return $display_text;
}, 10, 1 );

Attributes:

$display_text – String to display

Change the text for the One-time purchase radio option

↑ Back to top

Description:
bos4w_one_time_buy_text – change the text for the One-time purchase radio option displayed on the product page

Usage:

add_filter( 'bos4w_one_time_buy_text', function ( $display_text ) {
   // custom code
   return $display_text;
}, 10, 1 );

Attributes:
$display_text – Radio option text.

Change the text and discount display in the radio button for the subscription purchase option

↑ Back to top

Description:
bos4w_and_save_up_to_text – change the text and discount for the radio button for the subscription purchase option displayed on the product page

Usage:

add_filter('bos4w_and_save_up_to_text', function($text,$discount) {
   $text = 'Custom text be added';
   return $text;
}, 10, 2);

Attributes:
$text – Radio option text.
$discount – highest discount set for the product.

Change the text for the frequency dropdown label

↑ Back to top

Description:
bos4w_dropdown_label_text – change the text for the frequency dropdown label displayed on the product page

Usage:

add_filter( 'bos4w_dropdown_label_text', function( $text ) {
   $text = 'Custom text';

   return $text;
}, 10, 1 );

Attributes:
$text – Dropdown label text.

Change the text, interval, and discount display in the frequency dropdown

↑ Back to top

Description:
ssd_subscription_plan_display – change the text, interval, and discount display in the subscription dropdown options on the product page.

Usage:

add_filter( 'ssd_subscription_plan_display', function( $option_text, $period_interval, $discounted_price, $display_discount ) {
   return $option_text;  
}, 10, 4);

Attributes:
$option_text – The discount select text.
$period_interval – Period interval.
$discounted_price – The discounted price.
$display_discount – The discount percentage.

Filters for changing various plugin functionalities

↑ Back to top

Filter for changing the BOS products query attributes

↑ Back to top

Description:
bos4w_product_query_args – contains the query attributes used in wc_get_products() function.

Usage:

add_filter( 'bos4w_product_query_args', function( $prod_args ) { 
   // custom code  <br>
   return $prod_args; 
}, 10, 1 );

Attributes:
$prod_args – wc_get_products() query attributes.

Filter for changing the “Select options” button text

↑ Back to top

Description:
bos4w_add_to_cart_text – allow text change on the “Select options” button.

Usage:

add_filter( 'bos4w_add_to_cart_text', function custom_switch_item_text( $button_text, $product ) {
   return 'Select options';  
}, 10, 2);

Attributes:
$button_text – The button text.
$product – Product object.

Filter for using the regular price instead of the sale price when the product is bought as a subscription

↑ Back to top

By default, the plugin will use the sale price if there is one set on the product back-end page. You can use this filter if you want the subscription purchases to use the regular price when a sale price is set.

Description:

bos_use_regular_price – allows the use of the product’s regular price instead of the sale price. The default is set to false.

add_filter( 'bos_use_regular_price', function( $use_regular_price ) {
// If the return is false, it will use the Sale Price, if any. If not it will use the Regular Price.
// If the return is true, it will use only the Regular Price.
return true;
}, 10, 1 );

Attributes:

$use_regular_price – bool true/false.

Use of your personal data
We and our partners process your personal data (such as browsing data, IP Addresses, cookie information, and other unique identifiers) based on your consent and/or our legitimate interest to optimize our website, marketing activities, and your user experience.