Hooks and Filters
This page lists the public actions and filters of ReturnDesk. All of them exist since version 1.0.0. Hooks that only run in the Pro edition are marked Pro.
Every hook, option, table and capability uses the prefix tsre. The PHP namespace is Themesic\Returns. Classes are internal and may change; the hooks on this page are the supported way to extend the plugin.
- Status and lifecycle actions
- Email hooks
- Integration hooks
- Wizard and front-end hooks
- Rules and refund filters
- Label and carrier filters
- Guest portal hooks (Pro)
- Internal hooks
- Admin screen extension points
- Templates and data
Status and lifecycle actions
tsre_return_created
Action, since 1.0.0. Fires after a return was created, and after automatic approval when that applies.
do_action( 'tsre_return_created', int $return_id, \Themesic\Returns\Model\ReturnRequest $return_request );
tsre_return_status_changed
Action, since 1.0.0. Fires after a return changed status. This is the hook to use for SMS, automation or notification plugins.
do_action( 'tsre_return_status_changed', int $return_id, string $old, string $new, array $context );
$context always has actor_type (customer, admin or system) and actor_id. It can also have admin_note, reason (a rejection reason), tracking_number and auto (true for automatic approval).
Status actions
Action, since 1.0.0. One action per status, named tsre_return_status_ followed by the status that was reached. It fires right after tsre_return_status_changed.
do_action( "tsre_return_status_{$to}", int $return_id, array $context );
The statuses are approved, rejected, label_sent, in_transit, received, inspected, resolved and cancelled. A return starts as requested without a status change, so use tsre_return_created for that. tsre_return_status_resolved is also the hook behind the tsre_return.resolved webhook.
add_action( 'tsre_return_status_received', function ( $return_id, $context ) {
error_log( 'Return ' . $return_id . ' was received.' );
}, 10, 2 );
tsre_credit_issued
Action, since 1.0.0. Pro. Fires after store credit was issued for a return. It also sends the "Store credit added" email.
do_action( 'tsre_credit_issued', int $customer_id, float $amount, int $return_id );
$amount includes the bonus.
Email hooks
Email trigger actions
Action, since 1.0.0. Every ReturnDesk email has a trigger action named like its id, which passes the return id and the context of the event. WooCommerce queues or sends the email from it, so the email settings (enabled, recipients, templates) apply.
do_action( $email_id, int $return_id, array $context );
| Email id | |
|---|---|
tsre_customer_return_requested | Return requested (customer) |
tsre_customer_return_approved | Return approved (customer) |
tsre_customer_return_rejected | Return rejected (customer) |
tsre_customer_return_received | Return received (customer) |
tsre_customer_return_resolved | Return resolved (customer) |
tsre_customer_return_cancelled | Return cancelled (customer). Not triggered when the customer cancels. |
tsre_admin_return_requested | Return requested (admin) |
tsre_admin_return_in_transit | Return in transit (admin) |
tsre_customer_return_reminder (Pro) | Return reminder (customer) |
The Pro email "Store credit added" is triggered by tsre_credit_issued.
tsre_email_return_approved_details
Action, since 1.0.0. Lets other code add details to the approval email, in both the HTML and the plain text version, for example a prepaid return label.
do_action( 'tsre_email_return_approved_details', \Themesic\Returns\Model\ReturnRequest $return_request, bool $sent_to_admin, bool $plain_text, \WC_Email $email );
tsre_label_download_url
Filter, since 1.0.0. The address the customer downloads the return label from, shown in the approval email. Empty hides the line. ReturnDesk adds a signed link valid for seven days.
apply_filters( 'tsre_label_download_url', string $url, \Themesic\Returns\Model\Label $label, \Themesic\Returns\Model\ReturnRequest $return_request );