Add Date_of_Last_Purchase custom Function

Add Date_of_Last_Purchase custom Function

I am looking for a way to create a simple custom function that will execute when a new sales order is created.  The function will set a custom field on the customer called "Date_Last_Purchase" to the current date.  So as ever new sales order comes in for a customer, the field is updated.  Could someone help me create this custom function?  It would be great if I could update the field in Zoho Inventory customers as well as Zoho CRM accounts.

We plan to use this to automate emails to customers who have not ordered in a certain number of days.

Thank you for the help!
Drabbies