Add Filters for Subscriptions admin panel
-
Dear Dev team,
I ‘ve just to install your plugin and have some tests
Could you please help us how to add some filter based on : { subscription_status } & { end_date } ?
Thanks and Regards,
The page I need help with: [log in to see the link]
-
Hello,
Thank you for reaching out to us.
As for the list of filters available in the Flexible Subscriptions plugin, please find them below along with some usage examples:
Filter hooks allow you to modify data used by the plugin.
fsub/product_add_to_cart_textCustomizes the “Add to Cart” button text for subscription products on single product pages.
- Type:
Filter- Parameters:
@param string $button_textThe default button text (e.g., “Sign up now”). @param \WC_Product $productThe subscription product object.- Return:
@return stringThe modified button text.
- Parameters:
- Usage Example:
add_filter( 'fsub/product_add_to_cart_text', function( $button_text, $product ) {
return 'Subscribe Today!';
}, 10, 2 );—
fsub/subscription_renewal/should_interrupt_renewalAllows you to interrupt the renewal process for a subscription. Return
falseto prevent the renewal order from being created.- Type:
Filter- Parameters:
@param bool $can_renewDefault istrue. @param \WPDesk\FlexibleSubscriptions\Subscription\Subscription $subscriptionThe subscription being renewed.- Return:
@return boolReturnfalseto stop the renewal.
- Parameters:
- Usage Example:
add_filter( 'fsub/subscription_renewal/should_interrupt_renewal', function( $can_renew, $subscription ) {
// Don't renew if a specific meta key is present.
if ( 'yes' === $subscription->get_meta( '_do_not_renew' ) ) {
return false;
}
return $can_renew;
}, 10, 2 );—
fsub/subscription/status_awaitingModifies the status a subscription is set to while it awaits payment for a renewal order.
- Type:
Filter- Parameters:
@param string $statusThe default status, which ison-hold. @param \WPDesk\FlexibleSubscriptions\Subscription\Subscription $subscriptionThe subscription object.- Return:
@return stringThe new status (e.g.,pending).
- Parameters:
- Usage Example:
add_filter( 'fsub/subscription/status_awaiting', function( $status, $subscription ) {
// Change the default awaiting status to 'pending'.
return 'pending';
}, 10, 2 );—
fsub/settings/tabsAllows adding or modifying tabs on the Flexible Subscriptions settings page, located at
WooCommerce → Flexible Subscriptions → Settings.- Type:
Filter- Parameters:
@param \WPDesk\FlexibleSubscriptions\Form\Fields\Tab[] $tabsAn array of tab objects. - Return:
@return arrayThe modified array of tab objects.
- Parameters:
- Usage Example:
/**
* This is an advanced example requiring knowledge of the plugin's form structure.
* You would need to create a custom class that extends
* \WPDesk\FlexibleSubscriptions\Form\Fields\Tab.
*/
add_filter( 'fsub/settings/tabs', function( $tabs ) {
// $tabs[] = new My_Custom_Settings_Tab();
return $tabs;
} );—
fsub/subscription/payment_metaAllows you to add custom payment metadata fields to the subscription details metabox in the admin panel.
- Type:
Filter- Parameters:
@param array $payment_meta_fieldsAn empty array by default. @param \WPDesk\FlexibleSubscriptions\Subscription\Subscription $subscriptionThe subscription object.- Return:
@return arrayA structured array of fields to be displayed.
- Parameters:
- Usage Example:
add_filter( 'fsub/subscription/payment_meta', function( $payment_meta_fields, $subscription ) {
$payment_meta_fields['my_gateway'] = [
'post_meta' => [
'_my_gateway_token' => [
'label' => __( 'My Gateway Token', 'my-text-domain' ),
'value' => $subscription->get_meta( '_my_gateway_token' ),
],
],
];
return $payment_meta_fields;
}, 10, 2 );—
fsub/admin/order/order_typesAllows you to add custom options to the order type filter dropdown on the admin orders list page.
- Type:
Filter- Parameters:
@param array $order_typesAn associative array of order types in the format'key' => 'Label'. - Return:
@return arrayThe modified array of order types.
- Parameters:
- Usage Example:
add_filter( 'fsub/admin/order/order_types', function( $order_types ) {
$order_types['my_custom_type'] = __( 'My Custom Order Type', 'my-text-domain' );
return $order_types;
} );—
fsub/admin/order/relationshipCustomizes the display name for an order’s relationship (e.g., “Renewal”) in the “Subscription History” metabox.
- Type:
Filter- Parameters:
@param string $subtypeThe default relationship name. @param \WC_Order $payment_requestThe related order object.- Return:
@return stringThe new relationship display name.
- Parameters:
- Usage Example:
add_filter( 'fsub/admin/order/relationship', function( $subtype, $payment_request ) {
if ( $payment_request->get_meta( '_is_special_renewal' ) ) {
return 'Special Renewal';
}
return $subtype;
}, 10, 2 );—
fsub/admin/order/subtype_query_argsModifies the query arguments when filtering orders by a custom subtype added via the
fsub/admin/order/order_typesfilter.- Type:
Filter- Parameters:
@param array $query_argsThe current query arguments. @param string $subtypeThe key of the custom subtype being filtered.- Return:
@return arrayThe modified query arguments. This should typically add ameta_query.
- Parameters:
- Usage Example:
// This example works in tandem with the 'fsub/admin/order/order_types' example.
add_filter( 'fsub/admin/order/subtype_query_args', function( $query_args, $subtype ) {
if ( 'my_custom_type' === $subtype ) {
$query_args['meta_query'][] = [
'key' => '_my_custom_order_meta',
'value' => 'yes',
];
}
return $query_args;
}, 10, 2 );—
fsub/cart/require_payment_on_trialForces the display and use of payment gateways even when the cart total is zero (e.g., for a free trial). This is useful for capturing payment tokens for future renewals.
- Type:
Filter- Parameters:
@param bool $force_paymentDefault isfalse. - Return:
@return boolSet totrueto force payment gateway selection.
- Parameters:
- Usage Example:
// Always require a payment method, even for free trials.
add_filter( 'fsub/cart/require_payment_on_trial', '__return_true' );—
fsub/payment/manual_renewal/enabledEnables or disables the manual renewal process. If disabled, only payment gateways that support automatic renewals will be available at checkout for subscription products.
- Type:
Filter- Parameters:
@param bool $is_enabledDefault istrue. - Return:
@return boolSet tofalseto disable manual renewals.
- Parameters:
- Usage Example:
// Force all subscriptions to use automatic payment gateways.
add_filter( 'fsub/payment/manual_renewal/enabled', '__return_false' );Please let me know if you have any further questions.
Kind regards,
Dear Dev team,
Thanks for your reply !
Currently, I ‘d like to add filter to subcriptions-list based on subscription-status : { active / on-hold / pending cancelation } with dropdown-type
Could you help us solve it ?
Thanks and Regards
Hello,
Thank you for your message!
To better assist you, could you please clarify whether you’re looking to add the filter for subscription status in the customer view of subscriptions or in the admin panel? This will help us understand your needs more clearly.
Currently, the plugin does not have an option for filtering subscriptions by status directly, but if you’re referring to the admin panel and would like to filter subscriptions by status (active, on-hold, pending cancellation), we can consider adding this feature if it aligns with your requirements.
Looking forward to your response.
Kind regards,
Dear Dev team,
Correctly,
Sorry that if I said not clearly. I ‘d like to mention about filter in admin panel
Thanks and Regards,
Tuan
Hello Tuan,
Thank you for the clarification.
As mentioned earlier, the plugin currently doesn’t have the functionality to filter subscriptions by status in the admin panel. However, this sounds like a useful feature, and I’ve added it to our list of potential updates for future versions.
If we are able to implement this functionality in the future, I will be sure to notify you.
Thanks again for your input, and please don’t hesitate to reach out if you have any other questions.
Kind regards,
Dear Dev team,
Thanks for your reply,
It’s great to hear that from you. I will wait this feature of your team
Thanks and Regards,
Tuan
Hello,
You’re most welcome.
I’m marking this thread as resolved. Our developers are aware of this request, and if it gets implemented in a future update, I will make sure to inform you.
Have a fantastic day,
Dear Dev team,
Could you help me how to add filter product_category or product in Subscription list ?
Thanks and Regards
Tuan
Hi Tuan,
Thank you for your message!
Currently, the Flexible Subscriptions plugin does not include a built-in filter hook that would allow filtering the subscription list by product or product category.
However, we’re open to adding such a filter in the future.
To better understand your needs and determine the best place to implement it, could you please provide a bit more context?For example:
- Where exactly do you want this filter to be applied? (e.g., admin panel, customer account page, custom query?)
- Should it be used for displaying data or modifying behavior?
- Are you building a custom integration or extending an existing view?
With this information, we’ll be able to consider adding the appropriate filter in the future.
Best regards,
- Type:
The topic ‘Add Filters for Subscriptions admin panel’ is closed to new replies.