10. Custom Fields of Orders

10. Custom Fields of Orders

Idea

Map custom WC checkout fields with custom Zoho Sales Order fields.

*Note: in this tutorial, we assume you have already configured Custom Fields in Zoho and in WooCommerce. If not, please follow the Zoho Inventory documentation, as well as install a Checkout Custom Fields plugin in your WooCommerce store.

1. Install the Checkout Field Editor plugin and create the custom fields in either Billing/Shipping/Additional, depending on your requirements.
2. Go to CommerceBird > Zoho Inventory > Custom Fields and map each Woo Custom Field with its respective Zoho Field. Simply type the Zoho custom field label the same way that you typed in Zoho Inventory > Settings > Items > Field Customisation.

End result:


Simply fill in the WooCommerce field name on the left side and the Zoho Field Label on the right side and click on save. Voila! Now you have enabled complete orders if you use custom fields!

How to sync the order’s Payment Method to Zoho:

The payment method is a standard field in Woo and not a custom field, so you will need to create a custom called “payment_method” for the order and then hide it on the Frontend with some CSS.
After that step, simply copy below code and paste it into your child theme – functions.php or custom plugin.

  1. add_action( 'woocommerce_checkout_update_order_meta', 'cmbird_checkout_field_update_order_meta' );
  2.  
  3. function cmbird_checkout_field_update_order_meta( $order_id ) {
  4.    $order = wc_get_order( $order_id );
  5.    $method = $order->get_payment_method();
       $order->update_meta_data( 'payment_method', $method );
  6.    $order->save();
  7. }

Sending Phone number as separate custom field: 

  1. add_action( 'woocommerce_checkout_update_order_meta', 'cmbird_checkout_field_update_order_meta' );

  2. function cmbird_checkout_field_update_order_meta( $order_id ) {
  3.     if ( isset($_POST['billing_phone']) ) {
  4.         $phone = sanitize_text_field($_POST['billing_phone']);
  5.         $order = wc_get_order( $order_id );
  6.         $order->update_meta_data( 'billing_phone', $phone ); // Store it in meta
  7.         $order->save(); // Save order changes
  8.     }
  9. }

    • Related Articles

    • Custom Fields Products

      Important To proceed, please ensure you have installed the ACF plugin (free). All you need to do is make sure the ACF Custom Fields names match the Custom Fields API Names in Zoho Inventory. Once you have done that, you can simply click on the Sync ...
    • 7. Items real-time sync from Zoho to Woo

      Enable real-time sync from Zoho to WooCommerce using Zoho Webhooks! *This feature requires the Premium plan! Setup: Setup a webhook called “Webhook Items”. See this link if you are new to webhooks. Create a new Webhook for the Module "Item". The ...
    • 8. Order Sync

      Via the Order Sync tab, you can manage all orders related settings. Enable auto sales order numbers (recommended) You can also enable this to use the Zoho auto-generated sales order numbers instead of the woocommerce order numbers. When this is ...
    • Zoho Order to WooCommerce (How to)

      With the CommerceBird plugin, you can also sync Orders from Zoho Inventory or Books to WooCommerce. This requires the following: Premium plan of CommerceBird (upgrade via my-account if you are on business or free plan) Zoho Inventory integration ...
    • 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 Customisation. After mapping the taxes, we will start syncing the items. Please read below carefully. Mapping ...