1. Documentación /
  2. Buy Once or Subscribe for WooCommerce Subscriptions | Developer Hooks and Filters

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

Filters for changing strings

↑ Volver al principio

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

↑ Volver al principio

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

↑ Volver al principio

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

↑ Volver al principio

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

↑ Volver al principio

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

↑ Volver al principio

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

↑ Volver al principio

Filter for changing the BOS products query attributes

↑ Volver al principio

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

↑ Volver al principio

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

↑ Volver al principio

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 ) {
   // custom code
   return $use_regular_price;
}, 10, 1 );

Attributes:

$use_regular_price – bool true/false.