Skip to content
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

Need Help #276

Open
naresh-webkul opened this issue May 13, 2022 · 1 comment
Open

Need Help #276

naresh-webkul opened this issue May 13, 2022 · 1 comment

Comments

@naresh-webkul
Copy link

Hi,
i am migrating woo commerce site data and using the rest api doc (https://woocommerce.github.io/woocommerce-rest-api-docs/#introduction)

my woocommerce version: 4.5
rest api v3

The issue is i am not able to get the count of the data in the api response headers(like for customer i want total records of customer's and not able to get the total count of records that is in most of the case you will get from the response headers.

Also when i am using woocommerce v6.4.1 things are working fine i can get the total counts of records from the headers.

i am using an SDK to get the response(https://github.com/woocommerce/wc-api-php)
using the following method to get headers data($authenticate->http->getResponse()->getHeaders();) in both of the version that is v4.5 and 6.4.1 but not getting record count in headers in v4.5.
getting this in response header:

"access-control-expose-headers" => "X-WP-Total, X-WP-TotalPages, X-JWT-Refresh"

now how can i get these above "X-WP-Total, X-WP-TotalPages"

Can any one please describe.

Thanks!

@Neincriss
Copy link

Neincriss commented Jun 8, 2024

Were you able to obtain the headers “X-WP-Total, X-WP-TotalPages?

when you use a single query, you will not get these headers, but if you use a list query, you will get the information from these headers, using the query string “?per_page=<number_max_100>&page=<number_of_page>”.

for example making a query from a list to the products:

https://www.yourdomain.com/wp-json/wc/v3/products/?per_page=100&page=1

and the same for customers:

https://www.yourdomain.com/wp-json/wc/v3/customers/?per_page=100&page=1

in conclusion: don't query individually, if you want to get these headers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants