Function #28: Automatically calculate Customer Loyalty points

Function #28: Automatically calculate Customer Loyalty points

Hello everyone, and welcome back to our series! Today, we're excited to share a workflow designed to streamline the management of loyalty points. 

Many businesses offer incentives or rewards in the form of loyalty points to their customers as a way to promote recurring business and build customer loyalty. These points are typically earned by making purchases, which customers can accumulate over time and then redeem for various rewards, such as discounts, free products, credit points, gift cards, or other perks. 

Manually calculating the loyalty points for every customer's purchase can be a laborious and time-intensive process, particularly when you're managing a substantial customer base. But don't fret! Our custom function is here to save the day. The function will automatically calculate the loyalty points earned for each transaction and also generate a credit note once the specified limit is reached.

Here's how it works:

Whenever a customer makes a purchase and pays off the invoice in Zoho Books, the custom function gets executed. It calculates the loyalty points earned from that transaction and stores them in a custom field (created to accumulate the loyalty points). This process continues until the customer's loyalty point limit is reached. Then, the function automatically generates a credit note for the customer and resets their loyalty points. This credit note can be applied to the customer's next invoice, reducing the amount to be paid.



Prerequisites: 

1. Create a Connection named "zbooks" to successfully execute the function. You can watch the GIF attached below to learn how to create the connection.



2. Create a Number type custom field named "Loyalty points" for the Customers module. This field will store the points earned by a customer.




Custom Function:

Navigate to Settings -> Automation -> Custom Functions -> +New Custom Function > Add the function code from this GitHub link. Then, check and update the following variables as required.

1. minLoyaltyAmount - The purchase amount required for a customer to earn one loyalty point. For instance, if $500 spent equals 1 loyalty point, input 500 as the minLoyaltyAmount.
2. loyaltyFieldName - Copy and paste the API name of the custom field created in the Customers section to store loyalty points.
3. loyaltyLimit - Specify the limit to determine when loyalty points can be redeemed in the form of a credit note. For example, if a credit note should be generated when a customer accumulates 100 points, enter 100 as the loyaltyLimit.

Workflow Rule: 
 
Go to Settings -> Automation -> Workflow Rules -> +New Workflow Rule and set up the workflow rule as shown below:-






In the final step of this workflow rule, associate the custom function you created and then hit Save.

Should you require any help in customizing this function to better suit your requirements, don't hesitate to reach out to us at support[at]zohobooks[dot]com. We will be happy to assist you!

Regards,
Shireen Farhana 
Zoho Books

    Access your files securely from anywhere

        Zoho Developer Community




                                  Zoho Desk Resources

                                  • Desk Community Learning Series


                                  • Digest


                                  • Functions


                                  • Meetups


                                  • Kbase


                                  • Resources


                                  • Glossary


                                  • Desk Marketplace


                                  • MVP Corner


                                  • Word of the Day



                                      Zoho Marketing Automation


                                              Manage your brands on social media



                                                    Zoho TeamInbox Resources

                                                      Zoho DataPrep Resources



                                                        Zoho CRM Plus Resources

                                                          Zoho Books Resources


                                                            Zoho Subscriptions Resources

                                                              Zoho Projects Resources


                                                                Zoho Sprints Resources


                                                                  Qntrl Resources


                                                                    Zoho Creator Resources



                                                                        Zoho Campaigns Resources


                                                                          Zoho CRM Resources

                                                                          • CRM Community Learning Series

                                                                            CRM Community Learning Series


                                                                          • Kaizen

                                                                            Kaizen

                                                                          • Functions

                                                                            Functions

                                                                          • Meetups

                                                                            Meetups

                                                                          • Kbase

                                                                            Kbase

                                                                          • Resources

                                                                            Resources

                                                                          • Digest

                                                                            Digest

                                                                          • CRM Marketplace

                                                                            CRM Marketplace

                                                                          • MVP Corner

                                                                            MVP Corner





                                                                              Design. Discuss. Deliver.

                                                                              Create visually engaging stories with Zoho Show.

                                                                              Get Started Now