WOOSL/API_call/response_block

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

Type
Filter

Arguments
(array) $response
(array) $args

Description
Add additional data to the API current response block.

Observation
The cache module needs to be off for the filter to trigger. Or ensure the custom code is placed within the /wp-content/mu-plugins/woosl-custom.php file

Example of usage
Add the customer full name to the response.

    add_filter( 'WOOSL/API_call/response_block', '__woosl_api_additional_response', 10, 2 );
    function __woosl_api_additional_response ( $response, $args )
        {
            
            $licence_key_data = WOO_SL_functions::get_licence_key_data_by_licence_key( $args['licence_key'] );
            if ( ! is_object ( $licence_key_data ) )
                return $response;
                
            $response['customer_name']  =   get_post_meta( $licence_key_data->order_id, '_billing_first_name', TRUE ) . " " . get_post_meta( $licence_key_data->order_id, '_billing_last_name', TRUE );
            
            return $response;    
        }

By woocommerce-sl, posted on February 22, 2022

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments