boldcommerce / magento2-ordercomments

Add an order comments field in the default checkout for Magento 2.
MIT License
172 stars 86 forks source link

get order comment via API call #15

Closed affirmative-pl closed 6 years ago

affirmative-pl commented 6 years ago

Is it possible to download order comment using API?

I'm not an expert unfortunately, but the company that develops an application for me, claims it is not possible, making this module not feasible for my system. Could you please confirm if this attribute is visible to API calls?

Many thanks! Kate

boldsidney commented 6 years ago

hi @affirmative-pl

I had a quick look, and it currently doesn't seem possible to retrieve the comment using API.

Let me know if you still need this functionality. I'll be able to make some time next week to add this functionality there is still a need for it.

affirmative-pl commented 6 years ago

Hi, we'd love to have the attribute available via API, but we also noticed, while testing the module, that the way it limits comment size is not very user-friendly. It allows entering more characters than the limit states, and displays an error message. When more traditionally limits like this simply do not allow entering more characters, making it instantly obvious to the user, what to do.

obraz

boldsidney commented 6 years ago

hi @affirmative-pl , Thank you for your feedback regarding the comment limit functionality. I shall add it to my todo list for next week together with allowing the comments to be visible in the API.

affirmative-pl commented 6 years ago

hi @boldsidney, glad to hear you're going to take our feedback and enhance your module. I look forward to the update. Best wishes, Kate

boldsidney commented 6 years ago

hi @affirmative-pl , The update to 1.3.0 is now available.

The comment limit functionality should now work as you described and the comment is now visible through the /V1/orders/{id} route of the salesOrderRepositoryV1 API.

affirmative-pl commented 6 years ago

Thanks @boldsidney We'll give it a go!

affirmative-pl commented 6 years ago

Hi @boldsidney Unfortunately, we are not seeing the comments via /V1/orders/{id} route Can you give us more details on this field, please Thanks you Kate

boldsidney commented 6 years ago

hi @affirmative-pl , the data should be part of the extension_attributes field field_in_api

andrewbgittus commented 6 years ago

Hi @boldsidney

Our client Nutri-gold has your addon and I believe they're the ones who requested this functionality. Within our product, Zynk, we're making a request to the GET /index.php/rest/default/V1/orders Magento endpoint but within the data we're receiving from the website the field 'bold_order_comment' doesn't appear within the extension attributes collection within the raw JSON data we receive from their site.

{ "items": [ { "applied_rule_ids": "1", "base_currency_code": "GBP", "base_discount_amount": 0, "base_discount_invoiced": 0, "base_grand_total": 69.92, "base_discount_tax_compensation_amount": 0, "base_discount_tax_compensation_invoiced": 0, "base_shipping_amount": 0, "base_shipping_discount_amount": 0, "base_shipping_discount_tax_compensation_amnt": 0, "base_shipping_incl_tax": 0, "base_shipping_invoiced": 0, "base_shipping_tax_amount": 0, "base_subtotal": 58.27, "base_subtotal_incl_tax": 69.92, "base_subtotal_invoiced": 58.27, "base_tax_amount": 11.65, "base_tax_invoiced": 11.65, "base_total_due": 0, "base_total_invoiced": 69.92, "base_total_invoiced_cost": 0, "base_total_paid": 69.92, "base_to_global_rate": 1, "base_to_order_rate": 1, "billing_address_id": 32, "created_at": "2018-04-05 09:05:19", "customer_email": "xxx@xxxxx.co.uk", "customer_firstname": "Kate", "customer_gender": 0, "customer_group_id": 2, "customer_id": 12098, "customer_is_guest": 0, "customer_lastname": "xxxxx", "customer_note_notify": 1, "discount_amount": 0, "discount_description": "Buy 3 Get 1 Free", "discount_invoiced": 0, "email_sent": 1, "entity_id": 17, "global_currency_code": "GBP", "grand_total": 69.92, "discount_tax_compensation_amount": 0, "discount_tax_compensation_invoiced": 0, "increment_id": "500000013", "is_virtual": 0, "order_currency_code": "GBP", "protect_code": "xxxxxxxxxx", "quote_id": 41, "remote_ip": "", "shipping_amount": 0, "shipping_description": "Service - Royal Mail 1st Class Packet Post", "shipping_discount_amount": 0, "shipping_discount_tax_compensation_amount": 0, "shipping_incl_tax": 0, "shipping_invoiced": 0, "shipping_tax_amount": 0, "state": "processing", "status": "processing", "store_currency_code": "GBP", "store_id": 1, "store_name": "Main Website\nMain Website Store\n", "store_to_base_rate": 0, "store_to_order_rate": 0, "subtotal": 58.27, "subtotal_incl_tax": 69.92, "subtotal_invoiced": 58.27, "tax_amount": 11.65, "tax_invoiced": 11.65, "total_due": 0, "total_invoiced": 69.92, "total_item_count": 4, "total_paid": 69.92, "total_qty_ordered": 5, "updated_at": "2018-04-05 09:05:44", "weight": 1.7893, "items": [ { ... }, { ... }, { ... }, { ... } ], "billing_address": { ... }, "payment": { ... ], "amount_ordered": 69.92, "amount_paid": 69.92, "base_amount_ordered": 69.92, "base_amount_paid": 69.92, "base_shipping_amount": 0, "base_shipping_captured": 0, "cc_last4": null, "entity_id": 17, "last_trans_id": "", "method": "realexpayments_hpp", "parent_id": 17, "shipping_amount": 0, "shipping_captured": 0 }, "status_histories": [ { "comment": "Invoiced amount of \u00a369.92 Transaction ID: ", "created_at": "2018-04-05 09:05:43", "entity_id": 65, "entity_name": "order", "is_customer_notified": null, "is_visible_on_front": 0, "parent_id": 17 }, { "comment": "Authorised amount of \u00a369.92 Transaction ID:", "created_at": "2018-04-05 09:05:43", "entity_id": 64, "entity_name": "order", "is_customer_notified": null, "is_visible_on_front": 0, "parent_id": 17 }, { "comment": null, "created_at": "2018-04-05 09:05:19", "entity_id": 63, "entity_name": "order", "is_customer_notified": 1, "is_visible_on_front": 0, "parent_id": 17, "status": "pending" } ], "extension_attributes": { "shipping_assignments": [ { "shipping": { "address": { ... }, "method": "xxxxxxxx", "total": { "base_shipping_amount": 0, "base_shipping_discount_amount": 0, "base_shipping_discount_tax_compensation_amnt": 0, "base_shipping_incl_tax": 0, "base_shipping_invoiced": 0, "base_shipping_tax_amount": 0, "shipping_amount": 0, "shipping_discount_amount": 0, "shipping_discount_tax_compensation_amount": 0, "shipping_incl_tax": 0, "shipping_invoiced": 0, "shipping_tax_amount": 0 } }, "items": [ ... ] } ] } } ], "search_criteria": { "filter_groups": [ { "filters": [ { "field": "increment_id", "value": "500000013", "condition_type": "eq" } ] } ], "page_size": 50, "current_page": 1 }, "total_count": 1 }

boldsidney commented 6 years ago

hi @andrewbgittus,

That looks like the GET /V1/orders call, to display a list of orders. Can you try with the GET /V1/orders/{id} call, I've only added the field to that one.

If the GET /V1/orders/{id} isnt usable for your workflow i could look into also adding it to the list view GET /V1/orders later at the end of this week.

andrewbgittus commented 6 years ago

That's definitely the cause of the issue, within Zynk we use the /index.php/rest/default/V1/orders endpoint as it means within integrations we can essentially request new orders without knowledge of the increment_id and then process these orders into the relevant system.

Thanks @boldsidney I'll pass this onto the client.

dcabrejas commented 6 years ago

Hi @boldsidney

Thank you very much for the module, it works great. FYI we also find ourselves needing that field in the /rest/default/V1/orders endpoint for an integration. I think it would be quite a nice addition to the module.

danslo commented 6 years ago

I have a pull request open for this: https://github.com/boldcommerce/magento2-ordercomments/pull/18

boldsidney commented 6 years ago

Hi @danslo thank you for building this feature.

@andrewbgittus , @dcabrejas You can now update to version 1.4.0 to retrieve comments from the /V1/orders endpoint.

dcabrejas commented 6 years ago

Thanks @danslo @boldsidney