1. Documentation /
  2. Self-service Dashboard for WooCommerce Subscriptions | Developer Hooks and Filters

Self-service Dashboard for WooCommerce Subscriptions | Developer Hooks and Filters

Make sure you have a child theme otherwise, this code will get deleted by WordPress when you will update the theme next time.

Hooks

↑ Back to top

Add a simple product to a subscription

↑ Back to top

Description:
ssd_add_simple_product_before_calculate_totals – fired after a new simple product has been added to the subscription.

Usage:

add_action( 'ssd_add_simple_product_before_calculate_totals', function( $subscription, $product ) {
   // custom code
}, 10, 2 );

Attributes:
$subscription – Subscription object data;
$item_id – The ID of the item with quantity updated;
$product – Product object data.

Add a variable product to a subscription

↑ Back to top

Description:
ssd_add_variable_product_before_calculate_totals – fired after a new variable product has been added to the subscription.

Usage:

add_action( 'ssd_add_variable_product_before_calculate_totals', function( $subscription, $product, $variable_id ) {
   // custom code
}, 10, 3 );

Attributes:
$subscription – Subscription object data;
$product – Product object data;
$variable_id – The product variable id.

Pause a subscription until a specified date

↑ Back to top

Description:
ssd_pause_subscription – fired after the subscription is paused.

Usage:

add_action( ssd_pause_subscription, function( $subscription_id, $pause_date ) {
// custom code
}, 10, 2 );

Attributes:
$subscription_id – Subscription id;
$pause_datet – The date until the subscription it’s paused.

Quantity update hook before calculating totals

↑ Back to top

Description:
ssd_quantity_update_before_calculate_totals – fired after the subscription item quantity gets updated.

Usage:

add_action( 'ssd_quantity_update_before_calculate_totals', function( $subscription, $item_id, $qty ) {
   // custom code
}, 10, 3 );

Attributes:
$subscription – Subscription object data;
$item_id – The ID of the item with quantity updated;
$qty – The new quantity for the item.

Update subscription variable item before calculating totals

↑ Back to top

Description:
ssd_update_variable_item_before_calculate_totals – fired after the subscription variable item gets updated.

Usage:

add_action( 'ssd_update_variable_item_before_calculate_totals', function( $subscription , $item_id, $product, $variation_id ) {
   // custom code
}, 10, 4 );

Attributes:
$subscription – Subscription object data;
$item_id – The ID of the item with quantity updated;
$product – Product object data;
$variation_id – Variation ID;

Filters

↑ Back to top

Filter for changing the “Switch item” button text

↑ Back to top

Description:
ssd_switch_item_text’ – allow text change on the “Switch item” button.

Usage:

add_filter( 'ssd_switch_item_text', 'custom_switch_item_text', 10, 1 );
   function custom_switch_item_text( $text ) {
   return 'Change monthly hapé';
}

Attributes:
$text – The button text.

Filter “Add new product” query arguments

↑ Back to top

Description:
ssd_product_query_args – allows query arguments to change. The filter allows you to change the WP_Query parameters used to get the products the user sees when adding a new item to a Subscription.

Usage:
add_filter( 'ssd_product_query_args', function( $args ) {
   // custom code
   return $args;
}, 10, 1 );

Attributes:
$args – wc_get_products arguments.

Filter “Add new product” product object

↑ Back to top

Description:
ssd_add_new_product_list – allows query arguments to change. The filter allows you to manipulate the object containing the list of products the user sees when adding a new item to a Subscription.

Usage:
add_filter( 'ssd_add_new_product_list', function( $products ) {
   // custom code
   return $products;
}, 10, 1 );

Attributes:
$products – products object.

Filter for changing the calendar limit for the Change next payment date functionality

↑ Back to top

Description:
ssd_calendar_number_of_days – a filter that can be used for changing the calendar limit (in number of days) for the Change next payment date functionality

Usage:

add_filter( 'ssd_calendar_number_of_days', function ( $days ) {
   $days = 45;
   return $days;
}, 10, 1 );

Attributes:
$days – number of days for the calendar limit.

Filter for changing the date format in the date picker used by the Change next payment date and Pause subscription functionalities

↑ Back to top

Description:
ssd_custom_date_format – a filter that can be used for changing the date format in the date picker used by the Change next payment date and Pause subscription functionalities

Usage:

add_filter( 'ssd_custom_date_format', function ( $date_format ) {
   return 'y-m-d';
}, 10, 1 );

Attributes:
$date_format – the date format

Supported date formats can be found here.

Filter for changing the Change next payment date button text

↑ Back to top

Description:

sf_payment_date_text – is a filter that will allow you to change the text for the Change next payment date button

Usage:

add_filter( 'sf_payment_date_text', function ( $text ) {
   return esc_html( 'Change your next payment' );
}, 10, 1 );

Back to main documentation.