note the woocommerce rest api keys for images:
meta_gallery = {
"key": "_harikrutfiwu_wcgallary",
"value": [{"url": img_url} for img_url in product_images]
}
meta_featured = { # thumbnails
"key": "_harikrutfiwu_url",
"value": product_images[0]
}
meta_featured_alt = {
"key": "_knawatfibu_alt",
"value": product_images[0]
}
meta_images.append(meta_featured)
product_data = {
"name": product_title,
"type": "simple",
"regular_price": str(product_price),
"price": str(product_price),
"sku": str(product_sku),
"description": product_description,
"short_description": product_short,
"status": "publish",
"categories": category_ids,
"meta_data": meta_images,
#"images": images,
"attributes":attributes_list
}
]]>Is there any other information I need to provide to send the orders?
Thanks
]]>Please note that the Legacy REST API is not compatible with High-Performance Order Storage. Upgrading the code that relies on the Legacy REST API to use the current WooCommerce REST API instead is highly recommended.
But woocommerce doesn’t need rest api to work, so can we just disable rest api and delete this plugin ?
Thank you.
]]>I’m currently working with the WooCommerce REST API to query all products. The endpoint I’m using is /wp-json/wc/v3/products
. By default, the API allows sorting (orderby
) by several object attributes, such as date
, id
, include
, title
, slug
, price
, popularity
, and rating
, with date
being the default sorting method.
However, I need to implement a sorting method by relevance
. While relevance
is a default sorting option within WooCommerce itself, it doesn’t seem to be available by default in the REST API, where date
is the preset default.
Could anyone guide me on how to add relevance
as a sorting option to the WooCommerce REST API for product queries? Any advice or pointers to documentation that might help with this would be greatly appreciated.
Thank you in advance for your assistance!
The api i am using :
const response = await fetch(my-website/wp-json/wc/v3/products/?post_type=product&search=searchTerm&page=${page}&per_page=10&orderby=relevance
,{method: ‘GET’,});
if (isset($order['line_items']) && is_array($order['line_items'])) {
$line_items_data = array();
foreach ($order['line_items'] as $item) {
$line_items_data[] = array(
'id' => $item['id'],
'name' => $item['name'],
'quantity' => $item['quantity'],
'price' => $item['price'],
'subtotal' => $item['subtotal'],
'total' => $item['total'],
'product_id' => $item['product_id'],
);
}
}
I initially removed the line ‘id’ => $item[‘id’] in $line_items_data[] array and the problem got temporarily solved, so now I had at least the above properties on the orders. but this led to the repetition of each order’s items and an increase in total price. This seems to be due to the lack of the identifier I had removed earlier. My question, therefore, is about the correct method of retrieving “id” in order line items.
Thanks in advance
Could someone explain this to me please? It is being displayed in my client site.
The WooCommerce Legacy REST API, currently enabled in this site, will be removed in WooCommerce 9.0. A separate WooCommerce extension will be available to keep it enabled.
I don’t know what this does or why it is required? If someone could enlighten me and advise what I do with this message would be great.
Thanks
]]>I thought the ID in the REST API documentation for Customers was the WooCommerce customer id and I think it is the WordPress USER ID.
The table for WooCommerce customer data is wc_customer_lookup so as a guest they do not show up when retrieving the other records.
Is there a way to GET from wc_customer_lookup to retrieve Guest Checkout customers?
]]>