WC API - Query across multiple products - wordpress

I am setting up a site (WP) which will essentially sell one type of product and integrating a mobile app (ionic).
Multiple vendors can sell (WC Vendors) the variable product on the site at different quantities (100 litres, 200 litres etc).
I need to be able to make a GET request to return each vendors variable product for that quantity.
e.g. Customer selects they want 300 litres in the mobile app, I then use the API to return all variable products for that quantity (300 litres). So in the end, I have a response which will contain something like below;
Vendor: Vendor 1, Product: Product Name, Quantity: 300 litres, Price: £200
Is this possible as the WC API stands now?

For anyone else struggling on this, I finally got it to work by using the tags as suggested above and to query by tags using this;
https://example.com/wp-json/wc/v3/products?tag=20?consumer_key=ck_xxxxxxxxxxxxxxxxx&consumer_secret=cs_2xxxxxxxxxxxxx

I think you need to rephrase this a little bit, But From what I can get. You have a Vendor and a Product that has a Quantity of 300 L which in the first place I'd recommend you Should avoid, Rather just use Liter , Now what I'd Recommend is Tag's.
You'd have your Vendors and products under Categories.
And you can Set Tags on Products that you'd like to have what you require.
Then When someone Selects 300L , 200L It will pull every Product with the Tag 200L And you'll be able to display them.
Official Document
/wp-json/wc/v3/products/tags/<id>
They have:
id integer Unique identifier for the resource. name string Tag name.
slug string An alphanumeric identifier for the resource unique to its type.
description string HTML description of the resource.
count integer Number of published products for the resource.

Related

Woocommerce total stock count for specific category

I'm looking for small help. I'm using this function in function.php. When I use a shortcode [total-product] I'll get for example "We have a total of 1000 products in stock".
Using Get the count of all "In stock" products in WooCommerce code, takes a number of products from all categories, but I need to get number just only from specific categories - not from all together.
I don't know how to change the SQL query to select from specific categories, eg by ID.
Is there any chance of counting the number of product "in stock" according to specific categories? Something like (I have no idea about Database structure of WP tables):
AND category_id LIKE '100;101;...' // one or more category IDs

Woocommerce - Need to delete products with no association to a categories with SQL or plugin

Background:
I inherited a website with a tremendously bloated product database. There are around 260 actual products which are translated using WPML into English and French which should make it for a total of 520 posts (for each product there is one same SKU two different IDs). However the total count of products in published status is over 720.
I exported all my products and realized that there is a third instance of some products with the same SKU and yet another ID but they are not associated to any category i.e The 'Categories' field is empty.
These are not variants are just ghost instances of the parent products.
Problem to solve:
I need to get rid of those 'ghost' products that have no Categories association. (I do have the list of offender IDs as a CSV)
If possible I would like to understand what those extra products. Can they be untranslated versions of the listing? are they just corrupted/invalid records?
I can do SQL or plugin or whatever it takes.
Difference in Product Count that shows invalid products
Thanks!
I've solved the problem by using the CLI shell in WordPress.
By simply SSHing into the backend I used the following syntax
wp wc product delete <ID> for trashing the product and you can add the --force to permanently delete it.
Having the list of offender IDs I just simply wrote a shell script that executed all the commands sequentially.

List WooCommerce Product Feed to Amazon Marketplace

I am using WordPress woocommerce. And using "List WooCommerce Product Feed to Amazon Marketplace" plugin for amazon listing from website. But in Report section I am getting below error:
Feed Processing Summary:
Number of records processed 1
Number of records successful 0
original-record-number sku error-code error-type error-message
1 67715 8560 Error SKU 67715, Missing Attributes standard_product_id. SKU 67715 doesn't match any ASINs. Make sure that all standard product ids (such as UPC, ISBN, EAN, or JAN codes) are correct. To create a new ASIN, include the following attributes: standard_product_id. Feed ID: 0. For more troubleshooting help, see http://sellercentral.amazon.com/gp/errorcode/200692370
I have added GTIN in product and my GTIN # is: 677151310900
Kindly help me to solve this problem, also suggest if any better idea for listing in amazon.
Thanks in advance
Most probably, This kind of error occurs when any product is uploaded with different products information for any standard product ids like for your case having GTIN 677151310900 might be already listed by another seller with some other attributes values due to which they got failed to map those details with your products SKU information. In that case, they were asking to send only limited value such as you can just modify the products description, price, title and quantity rather than creating same products with others your custom data in Amazon catalog.
Thanks!

Custom loop for getting products flagged as new

I was looking for a way to build a custom loop to get the products flagged with the "new" label.
I could use the sort from the insert time, but that would always include a certain number of products, my goal here is to get those products that conform to the WooCommerce setting that says the product is considered new for a given number of days.
i have a free plugin - WooCommerce Product Badge, it has your requested feature to display "New" label with certain days defined.

Amazon MWS Report Type "_GET_MERCHANT_LISTINGS_DATA_" result attributes meaning

In Amazon MWS API, when requesting report of type "_GET_MERCHANT_LISTINGS_DATA_"
What is the difference between the returned attributes:
product-id
listing-id
asin1
I also have tried to find any reference for the tab-delimited report types, but it seems to be scattered all around the web. The best description I found was part of the instructions for the Amazon Inventory Loader. (Note: may require a MWS seller login, the corresponding XLS does not have all columns described on the linked webpage) That page should answer most of your questions.
Since the link above might require a login, here's a short description on what these columns do:
asin1 refers to an item's Amazon Standard Identification Number. Every item on Amazon has such a number, there even is a Wikipedia entry describing what it is.
product-id along with product-id-typerefers to the item's non-Amazon standard identification number, if such a thing exists (otherwise it'll contain a copy of the item's ASIN).
product-id-type=1 -> product-id is ASIN
product-id-type=2 -> product-id is ISBN.
product-id-type=3 -> product-id is UPC
product-id-type=4 -> product-id is EAN (now called GTIN)
sku is your own item identifier such as part number. You created the link between an ASIN and your own SKU by creating the product. (I know you didn't ask for this, but this is for the sake of completeness)
listing-id There does not seem to be a lot of documentation on what theses are. There is a page explaining how to find out an item's listing id. It does not say why you'd ever want to know, though. I assume a listing ID identifies a certain seller's (your) offer for a specific item, but all MWS requests I've ever done either required me to link to a ASIN or my own SKU, but there may be others that require this id.
Sidenote: I find it weird that a single listing-id may relate to more than one ASIN - otherwise, why are there columns named asin2 and asin3?

Resources