fbpx

Zoho Enhanced Ecommerce

#Overview

WP Fusion’s Ecommerce Addon (available for Plus and Professional license holders) supports sending ecommerce transaction data as Deals to your Zoho account account, for sales made in:

#Getting Started

Once you install the addon, Deals will automatically be added to Zoho when someone makes a purchase on your site. The default stage for new deals is Closed (Won), but you can change this via the Enhanced Ecommerce tab in the WP Fusion settings.

If you’ve just added a new stage, click Resynchronize on the Setup tab to load the latest options into the dropdown.

Because Zoho requires all deals to have a corresponding Account, you will also need to select an account from the Enhanced Ecommerce tab before deals can be created.

#How it Works

When a customer checks out on your site, WP Fusion will create a new deal in Zoho with the order label, date, and order total. This sale data will be associated with the contact record who made the purchase.

#How it Looks

WooCommerce orders shown in the Deals list in Zoho
The deal is created with the total order value and associated with the contact who made the purchase
The order details are added to the deal description field

#Products

If you have access to products in Zoho CRM, you’ll have the option to associate your WooCommerce products with existing Zoho products.

Note: Products in Zoho are available on the Professional plan and higher. For an overview of Zoho plans and features, see the Feature Availability chart.

To refresh the available options in the product dropdowns, click the Refresh Available Tags and Fields button from the main WP Fusion settings page.

If you do not select a product, a new one will be created automatically in Zoho the first time a customer checks out with that product.

Each time a customer purchases the product, it will be associated with the new deal in Zoho.

Note: Because each product requires a separate API call to create and associate with the deal, this can slow down the order processing time for orders that have many products.

If you are noticing slowness when syncing orders to Zoho, you can disable the Sync Products option on the Enhanced Ecommerce settings tab.

#Video – Enhanced Ecommerce – Zoho

#WooCommerce Order Statuses

If you’re using WooCommerce you can also associate each WooCommerce order status with a deal stage in Zoho. This setting appears under the Addons tab in the WP Fusion settings.

When the order status is updated in WooCommerce, the deal stage will be updated in Zoho.

Warning: It is recommended not to sync Pending payment orders with Zoho. When this is enabled, WP Fusion needs to create a contact record and a deal in Zoho as soon as the pending order is created in WooCommerce, and then update it less than a second later when the payment is processed.

This slows down your checkout with many duplicate API calls and in most cases isn’t necessary. A more performant method of tracking incomplete payments is to use Abandoned Cart Tracking.

Note: By default, running a WooCommerce Orders (Ecommerce addon) export operation from the Advanced settings tab will only export “paid” orders (Processing or Completed). However, if you have enabled additional order statuses for sync to a Zoho pipeline, then running the export will process those additional statuses as well.

This can be used to export refunded or cancelled orders to Zoho in addition to the paid orders.

#Modifying the API Data

WP Fusion supports using filters to modify the data sent to Zoho with an ecommerce order.

#Ignore Free Orders

This example bypasses creating a deal for any free orders.

function ignore_free_orders( $data, $order_id ) {
    if ( empty( $data['Amount'] ) ) {
        return false;
    }
    return $data;
}
add_filter( 'wpf_ecommerce_zoho_add_deal', 'ignore_free_orders', 10, 2 );

#Exclude Taxes

This example subtracts the amount of tax paid (if applicable) from the deal total.

function orders_tax_exclusive( $data, $order_id ) {
    $order = wc_get_order( $order_id );
    
    $data['Amount'] -= $order->get_total_tax();
    $data['Expected_Revenue'] -= $order->get_total_tax();
    
    return $data;
}
add_filter( 'wpf_ecommerce_zoho_add_deal', 'orders_tax_exclusive', 10, 2 );

#Custom Deal Fields

You can add custom fields to your Zoho deals using the wpf_ecommerce_zoho_add_deal filter. The data structure for Zoho deals includes standard fields like Deal_Name, Amount, Stage etc.

function my_custom_deal_properties( $data, $order_id ) {
    /* $data is structured like:
    $data = array(
        'Deal_Name'        => 'WooCommerce Order #123',
        'Account_Name'     => $account,
        'Contact_Name'     => $contact_id,
        'Closing_Date'     => date('Y-m-d'),
        'Stage'            => $stage,
        'Amount'           => 123.00,
        'Expected_Revenue' => 123.00,
        'Description'      => $description,
        'Currency'         => 'USD'
    ); */

    // Add custom field
    $data['Custom_Field'] = 'Custom Value';
    
    // Add order edit link
    $data['Order_Link'] = admin_url( 'post.php?post=' . $order_id . '&action=edit' );

    return $data;
}
add_filter( 'wpf_ecommerce_zoho_add_deal', 'my_custom_deal_properties', 10, 2 );

For more information, see the Zoho documentation on updating records.

#Add Additional Product Data

When syncing products to Zoho, you can modify the product data using the wpf_ecommerce_zoho_add_product filter:

function modify_product_data( $data, $product ) {
    /* $data is structured like:
    $data = array(
        'Product_Name' => $product['name'],
        'Unit_Price'   => $product['price']
    ); */

    // Add SKU
    $data['Product_Code'] = $product['sku'];
    
    // Add custom field
    $data['Custom_Product_Field'] = 'Custom Value';

    return $data;
}
add_filter( 'wpf_ecommerce_zoho_add_product', 'modify_product_data', 10, 2 );

Note: Make sure any custom fields you reference are already created in your Zoho CRM before attempting to sync data to them.

#Sync renewal orders to the parent order deal

By default WP Fusion will create a new deal in Zoho for each renewal order with WooCommerce Subscriptions.

This snippet checks to see if the order is a renewal order, and if so, updates the properties on the existing parent order’s deal, rather than creating a new deal.

Note that the custom properties in this snippet will need to first be created in the Zoho Deals module before they can be used. If you don’t need any of these properties in Zoho, you can just remove the lines from the code.

/**
 * Update existing Zoho deals from renewal orders.
 *
 * @param array $data The data to update.
 * @param int   $order_id The order ID.
 * @return array The data to update.
 */
function update_existing_zoho_deals_from_renewal_orders( $data, $order_id ) {

	$order = wc_get_order( $order_id );

	// Check if this is a renewal order
	if ( function_exists( 'wcs_order_contains_renewal' ) && wcs_order_contains_renewal( $order ) ) {

		// Get parent order ID
		$subscriptions = wcs_get_subscriptions_for_order( $order, array( 'order_type' => 'any' ) );

		if ( ! empty( $subscriptions ) ) {
			$subscription = array_pop( $subscriptions );
			$parent_order = $subscription->get_parent();

			if ( $parent_order ) {
				// Get the parent order's deal ID
				$parent_deal_id = $parent_order->get_meta( 'wpf_ec_zoho_invoice_id' );

				if ( ! empty( $parent_deal_id ) ) {
					// Set the ID so we update the existing deal rather than creating a new one.
					$data['id'] = $parent_deal_id;

					// Basic renewal info
					$data['Last_Renewal_Date']   = gmdate( 'Y-m-d', $order->get_date_created()->getTimestamp() );
					$data['Last_Renewal_Amount'] = $order->get_total();

					// Subscription status and dates
					$data['Subscription_Status']   = $subscription->get_status();
					$data['Next_Renewal_Date']     = $subscription->get_date( 'next_payment' );
					$data['Trial_End_Date']        = $subscription->get_date( 'trial_end' );
					$data['Subscription_End_Date'] = $subscription->get_date( 'end' );

					// Billing details
					$data['Billing_Period']   = $subscription->get_billing_period();
					$data['Billing_Interval'] = $subscription->get_billing_interval();

					// Subscription metrics
					$data['Total_Renewals']  = $subscription->get_payment_count();
					$data['Failed_Payments'] = $subscription->get_failed_payment_count();
					$data['Total_Revenue']   = $subscription->get_total();

					// Subscription products
					$items = array();
					foreach ( $subscription->get_items() as $item ) {
						$items[] = $item->get_name() . ' (x' . $item->get_quantity() . ')';
					}
					$data['Subscription_Products'] = implode( ', ', $items );

					// Customer metrics
					$data['Customer_Since'] = gmdate( 'Y-m-d', $parent_order->get_date_created()->getTimestamp() );
					$data['Payment_Method'] = $subscription->get_payment_method_title();

					// Calculate lifetime value
					$all_orders     = $subscription->get_related_orders();
					$lifetime_value = 0;
					foreach ( $all_orders as $related_order_id ) {
						$related_order = wc_get_order( $related_order_id );
						if ( $related_order && $related_order->is_paid() ) {
							$lifetime_value += $related_order->get_total();
						}
					}
					$data['Lifetime_Value'] = $lifetime_value;

					// Maybe update the cumulative deal amount
					$data['Amount']           = $lifetime_value;
					$data['Expected_Revenue'] = $lifetime_value;
				}
			}
		}
	}

	return $data;
}

add_filter( 'wpf_ecommerce_zoho_add_deal', 'update_existing_zoho_deals_from_renewal_orders', 10, 2 );

Was this helpful?