Hooks & Filters
All hooks are prefixed leet_rd_.
Filters#
| Filter | Arguments | Purpose |
|---|---|---|
leet_rd_approve_capability | string $capability | The capability needed to approve, reject, retry, revert and stage exceptions. Default edit_shop_orders. |
leet_rd_find_order_id | int $order_id, string $number | Return an order ID for a number the customer typed, for example with a sequential order number plugin. Return 0 to use the built-in lookup. |
leet_rd_client_ip | string $ip, string $remote | Change the client IP used for rate limits and lookup lockouts. |
leet_rd_claimed_qty | int $qty, WC_Order $order, int $item_id, int $exclude_case_id | Quantity of an order item already claimed by another open case. |
leet_rd_exchange_currency_supported | bool $supported, WC_Order $order | Return true to allow an exchange on an order paid in another currency than the shop’s. Default false. |
leet_rd_tracking_readers | array $readers | Add or remove tracking readers. Each reader is a callable that receives the order and returns a list of shipments. |
leet_rd_status_texts | array $texts, string $status | Label, remark and ETA text for an order status in status answers. Used when Leet Order Tracking is not active. |
leet_rd_credit_adapters | array $adapters | Register store credit adapters (objects implementing Leet_RD_Credit_Adapter). |
leet_rd_ledger_actions | array $actions | Register action handlers (objects implementing Leet_RD_Ledger_Action). |
leet_rd_ledger_can_execute | $allowed, array $proposal | Return a WP_Error to refuse executing a proposal, otherwise true. Checked at approve, at retry and under the locks. |
leet_rd_ledger_can_revert | $allowed, array $proposal | Return a WP_Error to refuse reverting an executed proposal, otherwise true. |
leet_rd_ai_client | Leet_RD_AI_Client $client | Replace the AI client. A return value that is not an Leet_RD_AI_Client is ignored. |
leet_rd_uploads_class | string $class | Replace the uploads class, mainly for tests. |
leet_rd_storeengine_store_url | string $url | The StoreEngine store URL used for license checks and updates. |
leet_rd_storeengine_product_id | int $product_id | The StoreEngine product ID. 0 disables licensing. |
leet_rd_store_dashboard_url | string $url | The account link shown on the License screen. |
leet_rd_storeengine_allow_local | bool $allow | Whether keys can be activated on local and .test sites. Default true. |
Actions#
| Action | Arguments | Fires when |
|---|---|---|
leet_rd_case_created | int $case_id | A case is created. |
leet_rd_case_status | int $case_id, string $from, string $to, array $context | A case changes status. |
leet_rd_case_needs_decision | int $case_id, string $reason, string $origin | A case needs your decision and nothing of it is waiting in the queue. Reason is policy, staging_failed or replacement_order. |
leet_rd_return_auth_reverted | int $case_id, array $proposal | A return authorization was withdrawn and its case is waiting for a decision again. |
leet_rd_ledger_proposed | int $id, array $proposal | A proposal is created. |
leet_rd_ledger_rejected | int $id, array $proposal | A proposal is rejected. |
leet_rd_ledger_executed | int $id, array $proposal, array $result | A proposal executed. |
leet_rd_ledger_reverted | int $id, array $proposal | An executed proposal is reverted. |
leet_rd_ledger_failed | int $id, array $proposal, WP_Error $error | A proposal failed to execute. |
leet_rd_settings_updated | string $group | A settings group was saved and logged. |
leet_rd_audit_failed | string $event, array $args | An activity log write failed. |
Examples#
Let a custom role approve proposals:
add_filter( 'leet_rd_approve_capability', function () {
return 'manage_woocommerce';
} );
Support a sequential order number plugin that stores numbers in your own meta key:
add_filter( 'leet_rd_find_order_id', function ( $order_id, $number ) {
$orders = wc_get_orders( array(
'limit' => 1,
'meta_key' => '_my_order_number',
'meta_value' => ltrim( $number, '#' ),
'return' => 'ids',
) );
return $orders ? (int) $orders[0] : $order_id;
}, 10, 2 );
React to a finished proposal:
add_action( 'leet_rd_ledger_executed', function ( $id, $proposal, $result ) {
error_log( 'Resolution Desk proposal ' . $id . ' executed.' );
}, 10, 3 );
The array keys of a proposal and of an execution result are internal to the ledger and are not documented as a public contract. Confirm which keys you want to promise to third parties before publishing a reference for them.
Was this article helpful?
Tell us what was missing
