woocommerce / woocommerce-rest-api

This is the WooCommerce core REST API Package. It runs standalone as a feature plugin too.
70 stars 46 forks source link

Need Help #276

Open naresh-webkul opened 2 years ago

naresh-webkul commented 2 years ago

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 commented 5 months ago

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=&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