Woocommerce REST API v3: Fetching multiple variations at once - woocommerce

I'm using the woocommerce library for nodejs to fetch product data.
The app already has all the product and variation ids, I just need to periodically fetch prices for the variations. I know I can use include: [ids...] to fetch multiple products at once, but it doesn't work when fetching variations. I also know I can fetch all variations of a single product, but with the number of products to fetch this generates too many requests.
Is there a better way to get multiple variations, or just their prices, within one API request?
Thank you

I'm sorry but there is no way to get all variations in one request.
You need to do a request for each variable product to get all variations that belong to that product.
To avoid too many requests you can add some sort of delay between each request so you don't get ratelimited if that's the problem.

Related

which servies to use for periodically load data from multiple data sources, aggregate and provide fast search?

Please propose a solution design for my case. The data comes from various sources, some from api, some from csv. A user will search using filters.
Ex: Product data (source 1) and Product Reviews ( Source 2). A user will search for a product with its name and rating.
Considerations:
When product reviews will keep on changing. So, the search should reflect that information.
In future, some more sources will get added and additional filters will get added. Ultimately, only products will be shown to the users.
Product price will change. The search results should give updated information.
The search should be very fast.
I looked into using apache airflow, mongodb and elastic search. However, i felt i am complicating the solution.

WooCommerce REST API - GET Orders since Order ID

I'm using the WooCommerce REST API to download Orders into our internal CRM database. We're currently doing this by requesting all Orders between 2 date ranges, e.g.
wp-json/wc/v2/orders?after=2018-05-08T00:00:00Z&before=2018-05-14T23:59:59Z&page=1&orderby=id&order=asc
and this is working well. We were wondering if it's possible to change this to just request all new orders since the last Order ID that we downloaded. For example if the last Order ID we downloaded was 2450 we would like to make a request to get all new Orders after 2450. I've been reading the docs for the parameters to list all Orders but not sure if this is actually possible?
At the time of writing this is not currently possible. Hopefully a future update to the API will allow this.

How to get bestselling and favorites products in rest API in woocommerce?

I want to get bestselling and favorites products from woocommerce site with rest API .
I read this site but not found any thing about that.
Does it exist any way to get that ?
For People Who are Still Stumbling upon this Question
As per WC v3 API. You can now pull Most Popular products through the API (which is the best selling product list as per my understanding);
GET /wp-json/wc/v3/products?orderby=popularity&order=desc
This should get you the most popular products in descending order by the number of sales. This is not currently documented (as of Feb 2, 2021).
Total list of possible orderby params are: date, id, include, title, slug, modified, menu_order, price, popularity, rating
Another part of the question asks for Favorite product API, which woo commerce doesn't have.
I can see that you can access bestsellers through reports. See here. As for favourites, I think this is done using third party plugins or custom code so I'm not sure how you are going to access this. But if I was to hazard a guess I would probably assume it would be under customer meta

Woocommerce API request returns few products

I have tried to retrieve all the products of a Woocommerce shop using this kind of request, but I only get 10 products:
http://www.mystore.com/wc-api/v3/products?oauth_consumer_key=ck_1234&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1488898708&oauth_nonce=a83kF3&oauth_signature=whatever
The only solution I found is to add a filter in the request in order to get a specific number of products, ex: &filter[limit]=1000. This works fine but the problem is that I need a generic solution because now I want to get products from multiple stores and some of them can have thousands of products.
Is there a better way to get all the products of a store without setting the limit?
OK, it seems that -1 is doing the job: &filter[limit]=-1 or filter%5Blimit%5D=-1
I will add a hint in case someone ends up in the same situation...
if you need to make an API call using Java, make sure you encrypt the above filter together with the rest authorization parameters so as to get the oauth signature.

Best Way to Pass variable to Woocommerce Product?

Here is the setup.
Customer fills out form of information for product specifications. This creates an entry in the db with a unique detailsID.
They then are taken to a product page, with many variables. They select the variable product and checkout.
Now in the db they have an order as well as a separate table with the details of their request.
What is the best way to connect the product they bought with the detailsID?
I would like to basically pass the detailsID to the product page, then add this detailsID to the product. Or add the orderID back into the details table.
I keep going around whether to add this as meta data, or use a session, or just do post order logic to add the order ID back into the details table.
I really just need to link the two once the order completes but am not sure the best method to do this. I am pretty new to Woocommerce so don't know a lot of the hooks yet.
Thank you so much for your suggestions!
After a lot of research and experimenting here is the method I have decided on. This seems to add the information in a variety of places to make it easy to track orders and to insure that the customer is getting the customized product they want.
add custom data to woocommerce
I am using this method very close to how it is spelled out in this great article. This was really helpful for me being a woocommerce newb.

Resources