Hello I have been having hard time solving the following problem I would like to show only order notes from woocommmerce with the value "customer_note": true , see the Json request downward
{
"id": 281,
"author": "system",
"date_created": "2017-03-21T16:46:41",
"date_created_gmt": "2017-03-21T19:46:41",
"note": "Order ok!!!",
"customer_note": false,
}
This is how the data from order notes is held in my flutter code.
@override
Future<List<OrderNote>> getOrderNote(
{String? userId, String? orderId}) async {
try {
var response = await wcApi
.getAsync('orders/$orderId/notes?customer=$userId&per_page=20');
var list = <OrderNote>[];
if (response is Map && isNotBlank(response['message'])) {
throw Exception(response['message']);
} else {
for (var item in response) {
// if (item.type == 'customer') {
/// it is possible to update to `any` note
/// ref: https://woocommerce.github.io/woocommerce-rest-api-docs/#list-all-order-notes
list.add(OrderNote.fromJson(item));
// }
}
return list;
}
} catch (e) {
rethrow;
}
}
2
Answers
I Also filter the order note containing a specific word with the following
What about adding a condition inside the for loop to check the value of
customer_note
in the item to decide whether to add it to the list or not like the following: