Function #61: Automatically add free item to the invoice based on item quantity

Function #61: Automatically add free item to the invoice based on item quantity



Hello everyone, and welcome back to another Custom Function Friday!

During holiday seasons or special promotions, businesses offer deals like BOGO (Buy One, Get One), Buy 3 Get 1 Free, Buy 2 at 50% off, and much more to attract customers. These promotions encourage buyers to take advantage of limited-time offers, helping them save money while increasing foot traffic for businesses. In today's post, we’ll show you how to automate one such promotional offer – the 'Buy N items and Get X as free' using a custom function in Zoho Books.

Prerequisites: 

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



2. Create a Lookup type custom field for Items. This field lets you choose the item to be given for free when a customer purchases a specified quantity of the same item. You can either select the same item as the free item or choose a different one.


3. Create a Check Box type custom field for Invoices. When creating an invoice, tick this field if you want to apply the offer to that particular invoice.




Custom Function:

Navigate to Settings -> Automation -> Workflow Actions -> Custom Functions -> +New Custom Function > Add the function code from this GitHub link -> Save. 



In line 10 of the script, you'll see the node "freeItemQTY". This is where you need to specify the minimum quantity a customer must purchase to qualify for a free item. For example, if the offer is Buy 5, Get 1 Free, then you would enter "5" here.

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.

Here's how it works:

Zylker Stationery has launched several promotional offers to boost sales during the back-to-school season. One of these offers is "Buy 6 Brushes, Get a Palette for Free." To implement this in Zoho Books, the first step is to designate the Palette as the free item associated with the purchase of Brushes in the Lookup custom field. The "freeItemQTY" node in the script should be set to 6.

When creating an invoice, the user must tick the checkbox custom field to apply the promotion, add the items, and save the invoice as a draft. Subsequently, the custom function will get executed,  automatically adding the Palette as a separate line item priced at zero. The updated invoice will then be sent to the selected customers.

If you’ve been running promotions like this and adding the free items manually every time you create an invoice, this function will really help save you time and effort! Give it a try and let us know how it goes. Additionally, we previously shared another function that automatically adds free items based on the invoice amount—be sure to check it out [here]. If you have any other use cases you'd like to automate in Zoho Books, drop an email to support[at]zohobooks[dot]com, and we can explore the possibilities.

Regards,
Shireen Farhana
Zoho Books


    Zoho Desk Resources

    • Desk Community Learning Series


    • Digest


    • Functions


    • Meetups


    • Kbase


    • Resources


    • Glossary


    • Desk Marketplace


    • MVP Corner


    • Word of the Day


      Zoho CRM Plus Resources

        Zoho Books Resources


          Zoho Subscriptions Resources

            Zoho Projects Resources


              Zoho Sprints Resources


                Zoho Orchestly Resources


                  Zoho Creator Resources


                    Zoho WorkDrive Resources



                      Zoho Campaigns Resources

                        Zoho CRM Resources

                        • CRM Community Learning Series

                          CRM Community Learning Series


                        • Tips

                          Tips

                        • Functions

                          Functions

                        • Meetups

                          Meetups

                        • Kbase

                          Kbase

                        • Resources

                          Resources

                        • Digest

                          Digest

                        • CRM Marketplace

                          CRM Marketplace

                        • MVP Corner

                          MVP Corner




                          Zoho Writer Writer

                          Get Started. Write Away!

                          Writer is a powerful online word processor, designed for collaborative work.

                            Zoho CRM コンテンツ




                              ご検討中の方