Hello, everyone! Welcome back to our series.
It's the holiday season, marking a time when businesses witness increased demand for products and services, leading to a significant boost in sales. This also presents an opportunity for businesses to engage with their customers. As a gesture of appreciation and gratitude, many businesses opt to include complimentary items with customer purchases to enhance the overall shopping experience. Today, we bring you a custom function that automatically adds a complimentary/free item to the invoice based on the total purchase amount.
Prerequisites:
1. Create a
Connection named
"zbooks" to successfully execute the function. You can watch the GIF attached below to know how to create the connection.
2. The items that will be given as free should exist under the Items module in Zoho Books.
3. To determine both when and what item should be given as complimentary, define distinct rate slabs in the script and assign a corresponding free item to each slab. In today's script, we have pre-defined 3 rate slabs.
If the invoice total is between $100 - $499, it is eligible for the free item A.
If the invoice total is between $500 - $999, it is eligible for the free item B.
If the invoice total is more than $1000, it is eligible for the free item C.
4. Create a Check Box-type custom field by the name "Include Free item?" for Invoices. Only when this field is ticked, the function will be executed to check the applicable rate slab.
Custom Function:
Navigate to Settings -> Automation -> Workflow Actions -> Custom Functions -> +New Custom Function > Add the function code from this
GitHub link.
Note: The custom function will be executed after the invoice is saved.
Here's how it works:
After creating ("Include Free item?" should be True) and saving an invoice, the custom function kicks in, checking the rate slab associated with the invoice. Based on the identified rate slab, the function automatically adds the corresponding free item.
Try out this function and drop your feedback in the comments section. If you have any specific customizations in mind, don't hesitate to reach out to our support desk at support[at]zohobooks[dot]com. We're here to assist you.
Stay tuned for our next custom function. Until then, have a joyful holiday season!
Regards,
Shireen Farhana
Zoho Books