woocommerce_rest_prepare_order_refund_preview
Filters the refund preview response before it is returned, following the woocommerce_rest_prepare_* family contract. The preview is advisory: the create path re-validates independently, so filtered values cannot bypass the creation guards.
Usage
add_filter( 'woocommerce_rest_prepare_order_refund_preview', 'wp_kama_woocommerce_rest_prepare_order_refund_preview_filter', 10, 3 );
/**
* Function for `woocommerce_rest_prepare_order_refund_preview` filter-hook.
*
* @param WP_REST_Response $response The preview response. Its data carries breakdown, subtotal,
* tax, total, max_refundable.
* @param WC_Order $order The order the refund preview was computed for.
* @param WP_REST_Request $request The request.
*
* @return WP_REST_Response
*/
function wp_kama_woocommerce_rest_prepare_order_refund_preview_filter( $response, $order, $request ){
// filter...
return $response;
}
- $response(WP_REST_Response)
- The preview response. Its data carries breakdown, subtotal, tax, total, max_refundable.
- $order(WC_Order)
- The order the refund preview was computed for.
- $request(WP_REST_Request)
- The request.
Changelog
| Since 11.1.0 | Introduced. |
Where the hook is called
woocommerce_rest_prepare_order_refund_preview
woocommerce/includes/rest-api/Controllers/Version3/class-wc-rest-order-refunds-controller.php 127
return apply_filters( 'woocommerce_rest_prepare_order_refund_preview', $response, $order, $request );