Skip to content

fixes kloon/WooCommerce-REST-API-Client-Library#154 #155

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion lib/woocommerce-api/class-wc-api-client-http-request.php
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,25 @@ protected function get_parsed_response( $raw_body ) {

$json = substr( $raw_body, $json_start, ( $json_end - $json_start ) );

return json_decode( $json, $this->json_decode_as_array );
$array = json_decode( $json, $this->json_decode_as_array );

return $this->get_extended_response($array);
}

/**
* Adds the response headers to the response
*
* Useful for pagination since the total number of resources and pages are always included
* in the X-WC-Total and X-WC-TotalPages HTTP headers.
*
* @param object|array $response
* @return mixed
*/
protected function get_extended_response( $response ) {

$response->header =$this->response->headers;

return $response;
}


Expand Down