Discussing APIs and development related to customers, discounts, and order management.
When fetching a customer record from either the REST API or the Graph API, the following values will be invalid for customers who have placed an order, but where the customer record itself has not actually been updated:
Note: The field values are incorrect in the REST API and the Graph API as well.
The root cause of this issue appears to be that the customer record is cached for a period of time (maybe forever?). Placing an order does not update the customer record or clear the cached data, and so the order-related fields do not appear as updated.
To prove this you can add a tag to the customer (which will trigger the customer to "update"), and now check the customer record. You will see that after updating the customer the orders_count and other fields are correct.
Clear the customer record cache whenever an order is placed for that customer.
Thanks for reporting this. I'm just chiming in to say I'm experiencing the same behavior. Even when trying to force an update, the value is still zero,.