Items real-time sync

Items real-time sync

Enable real-time sync from Zoho to WooCommerce using Zoho Webhooks!

*This feature requires the Premium plan!

Setup:

  1. Setup a webhook called “Webhook Items”. See this link if you are new to webhooks.

  2. Create a new Webhook for the Module "Item". The webhook should be POST method with your domain as base and ‘wp-json/v2/zoho-product’ as the endpoint slug: https://mydomain.com/wp-json/v2/zoho-product/
    webhook zoho item
  3. Then go to Workflows and Create new Workflow called "Product to Woo" (or other name) and use the following trigger:
 

Select below options for the workflow


Then simply link the webhook the above workflow: 

Repeat all the above steps now for "Inventory Adjustments" webhook type! 

End result:

What data will get synced:

  • Product Name
  • Price
  • SKU
  • Dimensions & Weight
  • Featured Image
  • Description
  • Brand (requires custom taxonomy "product_brand" in your wordpress site)
  • Tags (requires a custom field "tags" in zoho > preferences > items > field customization)
  • Stock (via the "inventory adjustments" webhook type)

How to trigger Item Webhook when a new Sales Order is confirmed

Unfortunately the Item Webhooks are not triggered when a new Sales Order is created. For some stores this might cause problems with up-to-date stock level data to the store, especially when you have a high order frequentie. There is only one solution for this, namely to create a custom function and having that linked to a Sales Order Workflow Rule. 

First create a custom field for items called "textarea" for example. If you give it a different name, then please make sure to copy the API name as you will need it in the code below.

1. Create a Custom Function via Settings > Webhook Actions > Custom Functions


2. Click on "connections" and create a new connection. 

3. Give the application name called "zom" for example and find the scope "Full" and enable it like this:
Now click on "Create and Connect" to create the connection and to use it. 

4. Copy the below script and paste it into the script field, make sure to replace "organisation_id" with your actual organisation id:
// Update the Items custom field cf_textarea with a short random string 
salesorderID = salesorder.get("salesorder_id");
// Get the line items of the sales order 
items = salesorder.get("line_items");
// Iterate through each item and update cf_textarea 
itemLis = List();
for each  item in items
{
// get item id 
itemId = item.get("item_id");
// Generate a short random string (e.g., 9 characters) 
myList = {0,1,2,3,4,5,6,7,8,9,10,11,12};
passString = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
newList = "";
for each index i in myList
{
randnum = randomNumber(1,62);
newList = newList + substring(passString,randnum,randnum + 1);
}
unique_pass = replaceAll(newList,",","");
// info unique_pass;
// Update the cf_textarea field of the item 
itemmap = Map();
itemmap.put("item_id",itemId);
Linecfs = List();
cf = Map();
cf.put("api_name","cf_textarea");
cf.put("value",unique_pass);
Linecfs.add(cf);
itemmap.put("custom_fields",Linecfs);
itemLis.add(itemmap);
info itemmap;
response = zoho.inventory.updateRecord("Items","organisation_id",itemId,itemmap,"zom");
}
info response;
Then click on "Save".  The above code will generate a random value for the text field "textarea", which in turn will trigger the Item Webhook :)

5. Finally create or edit your Sales Order Workflow Rule and ensure the Custom Function is triggered whenever an Order is created or edited. 


    • Related Articles

    • 6. Products Sync

      *Please do not skip this step! Before we start the sync, please ensure you have activated “Category” in your Zoho settings > Items > Fields Customization. After mapping the taxes, we will start syncing the items. Please read below carefully. Mapping ...
    • Limit Product Sync to WooCommerce (How to)

      You might have items in Zoho that you do not wish to sync to WooCommerce and you find the categories selection a too broad solution. There is a second solution to ensuring certain items do not get synced over to WooCommerce. Using Webhook Sync with ...
    • Reset Sync

      When to do this: When you made a major mistake in the sync setup process When you want to connect to another Zoho Organisation Steps to start over when mistake is made in Categories: Remove all the product categories Go to our plugin settings > Cron ...
    • 8. Order Sync

      Via the Order Sync tab, you can manage all orders related settings. Create Package This ensures the creation of a Shipping Package in Zoho Inventory right after the Sales Order is synced. This is useful if you have custom workflows to speed up the ...
    • 1. Getting Started

      Thank you for choosing the CommerceBird plugin. This guideline will ensure you can setup a real-time integration between your Zoho Inventory account and your WooCommerce store. Prerequisites: WordPress 6.2 or higher WooCommerce 8.0 or higher PHP 7.4 ...