Hooks
↑ Back to topAdd a simple product to a subscription (before the totals are calculated)
↑ Back to topDescription:
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 simple product to a subscription (before the product is added to the subscription)
↑ Back to topDescription:
ssd_add_simple_product_before_add_to_subscription – fired before a new simple product is added to the subscription.
Usage:
add_action( 'ssd_add_simple_product_before_add_to_subscription', function( $order, $product, $interval, $period ) {
// custom code
}, 10, 4 );
Attributes:
$order – Subscription object data;
$product – Product object data;
$interval – Subscription interval;
$period – Subscription periods.
Add a simple product to a subscription (after coupons have been applied)
↑ Back to topDescription:
ssd_add_simple_product_after_coupon_apply – fired after a new simple product is added to the subscription and after the coupons have been applied.
Usage:
add_action( 'ssd_add_simple_product_after_coupon_apply', function( $order, $product, $interval, $period ) {
// custom code
}, 10, 4 );
Attributes:
$order – Subscription object data;
$product – Product object data;
$interval – Subscription interval;
$period – Subscription periods.
Add a variable product to a subscription (before the totals are calculated)
↑ Back to topDescription:
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.
Add a variable product to a subscription (before the product is added to the subscription)
↑ Back to topDescription:
ssd_add_variable_product_before_add_product – fired before a new variable product is added to the subscription.
Usage:
add_action( 'ssd_add_variable_product_before_add_product', function( $order, $product, $variation_id, $interval, $period ) {
// custom code
}, 10, 5 );
Attributes:
$order – Subscription object data;
$product – Product object data;
$variation_id – Product Variation id;
$interval – Subscription interval;
$period – Subscription periods.
Add a variable product to a subscription (after coupons have been applied)
↑ Back to topDescription:
ssd_add_variable_product_after_coupon_apply – fired after a new variable product is added to the subscription and after the coupons are applied.
Usage:
add_action( 'ssd_add_variable_product_after_coupon_apply', function( $order, $product, $variation_id, $interval, $period ) {
// custom code
}, 10, 5 );
Attributes:
$order – Subscription object data;
$product – Product object data;
$variation_id – Product Variation id;
$interval – Subscription interval;
$period – Subscription periods.
Pause a subscription until a specified date
↑ Back to topDescription:
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 topDescription:
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 topDescription:
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;
Update Shipping details after the shipping method has been changed or updated
↑ Back to topDescription:
ssd_subscription_shipping_update – fired after the subscription’s shipping method has been changed or updated
Usage:
add_action( 'ssd_subscription_shipping_update', function( $subscription_id, $new_shipping ) {
// custom code
}, 10, 3 );
Attributes:
$subscription_id – Subscription ID;
$new_shipping – New shipping data.
Filters
↑ Back to topFilter for changing the “Switch item” button text
↑ Back to topDescription:
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 topDescription:
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 topDescription:
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 topDescription:
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 calendar limit for the Pause functionality
↑ Back to topDescription:
bos4w_max_pause_calendar_days – a filter that can be used for changing the calendar limit (in number of days) for the Pause functionality
Usage:
add_filter( 'bos4w_max_pause_calendar_days', function( $default ) {
return 14;// Set the calendar limit in days
});
Filter for changing the date format in the date picker used by the Change next payment date and Pause subscription functionalities
↑ Back to topDescription:
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 restricting the days available in the Change next payment date calendar
↑ Back to topDescription:
bos4w_restricted_weekdays – a filter that can restrict the available days in the Change next payment date calendar
Usage:
add_filter('bos4w_restricted_weekdays', 'my_custom_restricted_weekdays');
function my_custom_restricted_weekdays($restricted_weekdays) {
// Modify the $restricted_weekdays array as needed
$restricted_weekdays = array(0, 2, 3, 4, 5, 6); // Restrict All days except Monday
return $restricted_weekdays;
}
Attributes:
$restricted_weekdays – the days which will be restricted. These days will not be active.
Filter for restricting the days available in the Pause subscription calendar
↑ Back to topDescription:
bos4w_paused_restricted_weekdays – a filter that can restrict the available days in the Pause subscription calendar
Usage:
add_filter('bos4w_paused_restricted_weekdays', 'my_paused_restricted_weekdays');
function my_paused_restricted_weekdays($restricted_weekdays) {
// Modify the $restricted_weekdays array as needed
$restricted_weekdays = array(0, 2, 3, 4, 5, 6); // Restrict All days except Monday
return $restricted_weekdays;
}
Attributes:
$restricted_weekdays – the days which will be restricted. These days will not be active.
Filter for changing the renewal time
↑ Back to topDescription:
ssd_update_next_payment_date – a filter that can change the time when an order is renewed
Usage:
add_filter( 'ssd_update_next_payment_date', 'modify_next_payment_time', 10, 1 );
function modify_next_payment_time( $next_payment_date ) {
// Parse date and time from the input
$date = new DateTime($next_payment_date);
// Set the time you want
$date->setTime(14, 0); // change to the desired time, here it is 2 PM (24-hour format)
// converting back to date-time format
$new_date_time = $date->format('Y-m-d H:i:s');
return $new_date_time;
}
Attributes:
$new_date_time – the new time set for the renewal order
Filter for changing the Change next payment date button text
↑ Back to topDescription:
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 );
Filter for hiding the Update shipment pop-up
↑ Back to topDescription:
ssd_settings_tabs_display_item_shipping_update – is a filter that will allow you to hide the update shipping pop-up. The functionality in the pop-up will still execute.
Usage:
add_filter( 'ssd_settings_tabs_display_item_shipping_update', function( $value ) {
return 'no'; // Use the return value 'no' to hide
} );
Filter for updating the shipping info when the “ssd_subscription_shipping_update” hook triggers
↑ Back to topDescription:
ssd_filter_shipping_info – a filter that can update the shipping method set on the subscription.
Usage:
add_filter('ssd_filter_shipping_info', 'custom_update_shipping_based_on_total', 10, 2);
function custom_update_shipping_based_on_total($shipping_data, $subscription_id ) {
$shipping_data = array(
'shipping_method_title' => 'The new shipping method title',
'shipping_method_id' => 'The new shipping method ID',
'shipping_instance_id' => 'The new shipping instance ID',
'shipping_price' => 'The new shipping price',
);
return $shipping_data;
}
Attributes:
$shipping_data – The current shipping data containing details such as method ID, price, and title.
$subscription_id – The ID of the subscription for which the shipping data is being updated.
Filter for hiding the Update shipping pop-up on shipping method update
↑ Back to topDescription:
ssd_settings_tabs_display_item_shipping_update – a filter that can hide the pop-up for the shipping method update. Can be used to replace the customer selection with custom code
Usage:
add_filter( 'ssd_settings_tabs_display_item_shipping_update', function( $value ) {
return 'no'; //'no' will hide the pop-up and 'yes' will display it
} );
Filter for hiding the Add to subscription button from the Add new product modal
↑ Back to topDescription:
ssd_show_add_to_subscription_button – is a filter that will allow you to show/hide the Add to subscription button for certain products or product types
Usage:
add_filter( 'ssd_show_add_to_subscription_button', function( $show, $subscription_id, $product_id ) {
$product = wc_get_product( $product_id );
if ( 'simple' === $product->get_type() ) {
return false; //hide simple products
}
if ( 123 === $product_id ) {
return false; //hide product with ID 123
}
return $show;
}, 10, 3 );
Filter for hiding the Add to next shipment button from the Add new product modal
↑ Back to topDescription:
ssd_show_add_to_next_subscription_button – is a filter that will allow you to show/hide the Add to next shipment button for certain products or product types
Usage:
add_filter( 'ssd_show_add_to_next_subscription_button', function( $show, $subscription_id, $product_id ) {
$product = wc_get_product( $product_id );
if ( 'simple' === $product->get_type() ) {
return false; //hide simple products
}
if ( 123 === $product_id ) {
return false; //hide product with ID 123
}
return $show;
}, 10, 3 );
Back to main documentation.