WOOSL/API_call/arguments

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

Type
Filter

Arguments
(array) $args
(class) $api_object

Description
Allows filtering the argument data passed through the API.

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

Example of usage
Add additional argument.

        add_filter( 'WOOSL/API_call/arguments', 'WOOSL_API_call_arguments', 10, 3 );
        function WOOSL_API_call_arguments ( $args, $object )
            {
                
                $args['client_hash'] = md5( $_SERVER['HTTP_USER_AGENT'] );
                   
                return $args;  
            }

By woocommerce-sl, posted on August 2, 2017

Subscribe
Notify of
guest
2 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Manish Shah

Hi.
I am trying to add header(‘Access-Control-Allow-Origin: *’); as this –

add_filter( 'WOOSL/API_call/arguments', 'WOOSL_API_call_arguments', 10, 3 );
    function WOOSL_API_call_arguments ( $args, $object )
    {
      $args['headers'] = array('Access-Control-Allow-Origin' => '*');
      return $args;  
    }

Am I doing something wrong? It’s not working.
If I add header(‘Access-Control-Allow-Origin: *’); directly in includes/class.sl.api API_call() function then it works. I don’t want to edit the plugin file as the update will remove the code.