WOOSL/API_call/early_return

Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInPrint this page

Type
Filter

Arguments
(array) $response
(array) $args
(class) $api_object

Description
Allows filtering the API response by adding a custom response item on top of everything else.

Observation
The cache module need to be off for the filter to trigger.

Example of usage
Return additional response with a timestamp call, on top of the other API messages.

    add_filter( 'WOOSL/API_call/early_return', 'WOOSL_API_call_early_return', 10, 3 );
    function WOOSL_API_call_early_return ( $response, $args, $object )
        {
            
            $response[] =   array ( 
                                    'status'    =>  'success',
                                    'timestamp' =>  time(),
                                    'message'   =>  'API call time'
                                        );
               
            return $response;   
        }

By woocommerce-sl, posted on January 27, 2021