Extending API’s
-
How to extend My Orders API by getting product image with it.
-
Hey there!
You can find more information about product images via the API here:
https://woocommerce.github.io/woocommerce-rest-api-docs/#product-images-propertiesHow do I add / get product image in my orders api
Also to display product image in my orders page web
@fernashes how could i get the images array in order detail API
example.com/wp-json/wc/v3/orders/101?consumer_key=ck_xxxxxxx&consumer_secret=cs_xxxxx
output to get with the following in orders(particular/myOrders):
"images": [ { "id": 1296, "date_created": "2019-03-25T20:37:03", "date_created_gmt": "2019-03-25T10:07:03", "date_modified": "2019-03-25T20:37:03", "date_modified_gmt": "2019-03-25T10:07:03", "src": "https://example.com/wp-content/uploads/2019/03/nestle-milkmaid.jpg", "name": "-nestle-milkmaid", "alt": "", "position": 0 } ],-
This reply was modified 7 years ago by
Jan Dembowski.
-
This reply was modified 7 years ago by
Jan Dembowski. Reason: Formatting
@fernashes can you reply me on REST API extending i.e, i need to get the product image array in api
wp-json/wc/v2/orders/4166 –
“line_items”: [
{
“id”: 290,
“name”: “Brooke Bond-3 Roses Tea”,
“product_id”: 21,
“variation_id”: 0,
“quantity”: 1,
“tax_class”: “”,
“subtotal”: “54.00”,
“subtotal_tax”: “0.00”,
“total”: “54.00”,
“total_tax”: “0.00”,
“taxes”: [],
“meta_data”: [],
“sku”: “”,
“price”: 54
},in this i need to get product image
Hey @manigopal
This isn’t possible out of the box through the REST API, you will want to query the product ID that is returned and request the thumbnail for that product.
This post might help – https://stackoverflow.com/questions/30813815/show-products-image-in-orders-page-woocommerce
Thanks,
if we do that might be gone at future plugin updates., so if there any code like adding them to functions.php such like add_action()
Hi there,
I would do the following.
* Write a function that gets the values for you and accepts order ID as an argument.
* Register a custom endpoint for the function. https://developer.ww.wp.xz.cn/rest-api/extending-the-rest-api/adding-custom-endpoints/ – make sure this checks for credentials since order data should not be publicly accessible.Kind regards,
We haven’t heard back from you in a while, so I’m going to mark this as resolved – if you have any further questions, you can start a new thread.
Hi,
but its mandatory when we develop a mobile app we do require the Product Images to be fetched / retrieved at the order to display in My Order page too at MobileApps. -
This reply was modified 7 years ago by
The topic ‘Extending API’s’ is closed to new replies.