Introduction

This is an Frappe custom app, intended to add WooCommerce-specific features to ERPNext

This app allows you to synchronise your ERPNext site with multiple WooCommerce websites

Set up and configuration

  1. Configure WooCommerce Fusion

Features

  1. Two-way Sales Order Synchronisation: Create Sales Orders in ERPNext automatically and keep it synchronised with WooCommerce orders
  2. Two-way Item Synchronisation
  3. Sync Item Stock Levels from ERPNext to WooCommerce
  4. Sync Item Prices from ERPNext to WooCommerce
  5. Integration with WooCommerce Plugins

Feedback

Please raise issues for any bugs or enhancements here: https://github.com/dvdl16/woocommerce_fusion

Configure WooCommerce Fusion


The first step is to create a WooCommerce Server document, representing your WooCommerce website.

click on Add WooCommerce Server

Complete the "WooCommerce Server URL", "API consumer key" and "API consumer secret" fields. To find your API consumer key and secret, go to your WordPress admin panel and navigate to WooCommerce > Settings > Advanced > REST API, and click on "Add key". Make sure to add Read/Write permissions to the API key.

WooCommerce API Settings

New WooCommerce Server


Click on the "Sales Orders" tab and complete the mandatory fields

"Sales Orders" tab

Settings:

  • Synchronise Sales Order Line changes back

When set, adding/removing/changing Sales Order Lines will be synchronised back to the WooCommerce Order (Note: Sales Orders will always be synchronised, this setting is for sync'ing changed Sales Order Lines back to WooCommerce)

  • Enable Payments Sync

Let the app create Payment Entries for paid Sales Orders. A mapping of Payment Method to Bank Account is required:

{
   "bacs": "1000-000 Bank Account",
   "cheque": "1000-100 Other Bank Account"
}

Click on the "Items" tab if you want to turn on Stock Level Synchronisation

"Items" tab

Settings:

  • Default Item Code Naming Basis
    • How the item code should be determined when an item is created, either "WooCommerce ID" or "Product SKU".
  • Enable Stock Level Synchronisation
    • Turns on Syncrhonisation of Item Stock Levels to WooCommerce
  • Warehouses
    • Select the Warehouses that should be taken into account when synchronising Item Stock Levels

Click on the "Save" - and you are ready to go!

Sales Order Sync

Background Job

Every hour, a background task runs that performs the following steps:

  1. Retrieve a list of WooCommerce Orders that have been modified since the Last Syncronisation Date (on WooCommerce Integration Settings)
  2. Retrieve a list of ERPNext Sales Orders that are already linked to the WooCommerce Orders from Step 1
  3. Retrieve a list of ERPNext Sales Orders that have been modified since the Last Syncronisation Date (on WooCommerce Integration Settings)
  4. If necessary, retrieve a list of WooCommerce Orders that are already linked to the ERPNext Sales Orders from Step 3
  5. Compare each WooCommerce Order with its ERPNext Sales Orders counterpart, creating an order if it doesn't exist

Hooks

  • Every time a Sales Order is submitted, a synchronisation will take place for the Sales Order if:
    • A valid WooCommerce Server and WooCommerce ID is specified on Sales Order

In order to make this work you need to configure the webhook in both, ERPNext and WooCommerce:

  1. From ERPNext you need to get the access keys from the Woocommerce server configuration, in the WooCommerce Webhook Settings.
  2. Create the webhook inside WooCommerce using the "Order created" topic and the rest of the data obtained on step 1.

Manual Trigger

  • Sales Order Synchronisation can also be triggered from an Sales Order, by changing the field WooCommerce Status
  • Sales Order Synchronisation can also be triggered from an Sales Order, by clicking on Actions > Sync this Item with WooCommerce
  • Sales Order Synchronisation can also be triggered from a WooCommerce Order, by clicking on Actions > Sync this Order with ERPNext

Background Job

Every hour, a background task runs that performs the following steps:

  1. Retrieve a list of WooCommerce Orders that have been modified since the Last Syncronisation Date (on WooCommerce Integration Settings)
  2. Compare each WooCommerce Order with its ERPNext Sales Order counterpart, creating a Sales Order if it doesn't exist or updating the relevant Sales Order

Synchronisation Logic

When comparing a WooCommerce Order with it's counterpart ERPNext Sales Order, the date_modified field on WooCommerce Order is compared with the modified field of ERPNext Sales Order. The last modified document will be used as master when syncronising

Fields Mapping

WooCommerceERPNextNote
billingAddress with type BillingChecks if the email field matches an existing Customer's woocommerce_email field. If not, a new Customer is created.
Contact
shippingAdress with type Shipping
line_itemsItemChecks if a linked Item exists, else a new Item is created
idSales Order > Customer's Purchase Order
Sales Order > Woocommerce ID
currencySales Order > Currency

Troubleshooting

  • You can look at the list of WooCommerce Orders from within ERPNext by opening the WooCommerce Order doctype. This is a Virtual DocType that interacts directly with your WooCommerce site's API interface
  • Any errors during this process can be found under Error Log.
  • You can also check the Scheduled Job Log for the sync_sales_orders.run_sales_orders_sync Scheduled Job.
  • A history of all API calls made to your Wordpress Site can be found under WooCommerce Request Log

Items Sync

Setup

To link your ERPNext Item to a WooCommerce Product:

  • If the WooCommerce Product already exists, specify the WooCommerce ID and WooCommerce Server
  • If you want the item to be created in WooCommerce, specify only the WooCommerce Server

Linking an item

Hooks

  • Every time an Item is updated or created, a synchronisation will take place for the item if:
    • A row exists in the Item's WooCommerce Servers child table with a blank/empty WooCommerce ID and Enable Sync is ticked: A linked WooCommerce Product will be created, OR
    • A row exists in the Item's WooCommerce Servers child table with a value set in WooCommerce ID and Enable Sync is ticked: The existing WooCommerce Product will be updated

Manual Trigger

  • Item Synchronisation can also be triggered from an Item, by clicking on Actions > Sync this Item with WooCommerce
  • Item Synchronisation can also be triggered from a WooCommerce Item, by clicking on Actions > Sync this Product with ERPNext

Background Job

Every hour, a background task runs that performs the following steps:

  1. Retrieve a list of WooCommerce Products that have been modified since the Last Syncronisation Date (on WooCommerce Integration Settings)
  2. Compare each WooCommerce Product with its ERPNext Item counterpart, creating an Item if it doesn't exist or updating the relevant Item

Synchronisation Logic

When comparing a WooCommerce Item with it's counterpart ERPNext Item, the date_modified field on WooCommerce Item is compared with the modified field of ERPNext Item. The last modified document will be used as master when syncronising

Fields Mapping

WooCommerceERPNextNote
idItem CodeOnly if Default Item Code Naming Basis is set to WooCommerce ID on WooCommerce Server
skuItem CodeOnly if Default Item Code Naming Basis is set to Product SKU on WooCommerce Server
nameItem Name
typesimple ≡ Normal Item
variable ≡ Template Item (Has Variants is checked).
variantItem Variant (Variant Of is set)
attributesAttributesMissing *Item Attributes will automatically be created in both systems

Custom Fields Mapping

It is possible to map fields that you want to be synchronised. For example, to synchronise a WooCommerce Product's short_description field to an ERPNext Item's description field, add the following Field Mapping:

Item Fields Mapping

**Note that this is recommended for advanced users only. This is a very basic functionality - there are no field type conversions possible as of yet.

Troubleshooting

  • You can look at the list of WooCommerce Products from within ERPNext by opening the WooCommerce Product doctype. This is a Virtual DocType that interacts directly with your WooCommerce site's API interface
  • Any errors during this process can be found under Error Log.
  • You can also check the Scheduled Job Log for the sync_items.run_items_sync Scheduled Job.
  • A history of all API calls made to your Wordpress Site can be found under WooCommerce Request Log

Sync Item Stock Levels from ERPNext to WooCommerce

Sync item stock level

Background Job

If Stock Level Sync is enabled, every day, a background task runs that performs the following steps:

  1. Get all enabled items
  2. For every WooCommerce-linked item, sum all quantities from all warehouses and round the total down (WooCommerce API doesn't accept float values)
  3. For every item post the new stock level to WooCommerce

Hooks

If Stock Level Sync is enabled, a stock level API post will be made when the following documents are submitted or cancelled:

  • Stock Entry
  • Stock Reconciliation
  • Sales Invoice
  • Delivery Note

Manual Trigger

Stock Level Synchronisation can also be triggered from an Item, by clicking on Actions > Sync this Item's Stock Levels to WooCommerce

Troubleshooting

  • You can look at the list of WooCommerce Products from within ERPNext by opening the WooCommerce Product doctype. This is a Virtual DocType that interacts directly with your WooCommerce site's API interface
  • Any errors during this process can be found under Error Log.
  • You can also check the Scheduled Job Log for the stock_update.update_stock_levels_for_all_enabled_items_in_background Scheduled Job.
  • A history of all API calls made to your Wordpress Site can be found under WooCommerce Request Log

Sync Item Prices from ERPNext to WooCommerce

Sync item prices

Background Job

If Price List Sync is enabled, every day, a background task runs that performs the following steps:

  1. Get list of ERPNext Item Prices to synchronise, based on the Price List setting
  2. Synchronise Item Prices with WooCommerce Products

Hooks

If Price List Sync is enabled, a product update API request will be made when the following documents are updated:

  • Item Price

Manual Trigger

Price List Synchronisation can also be triggered from an Item, by clicking on Actions > Sync this Item's Price to WooCommerce

Troubleshooting

  • You can look at the list of WooCommerce Products from within ERPNext by opening the WooCommerce Product doctype. This is a Virtual DocType that interacts directly with your WooCommerce site's API interface
  • Any errors during this process can be found under Error Log.
  • You can also check the Scheduled Job Log for the sync_item_prices.run_item_price_sync Scheduled Job.
  • A history of all API calls made to your Wordpress Site can be found under WooCommerce Request Log

WooCommerce Plugins integration

Advanced Shipment Tracking

https://woocommerce.com/document/advanced-shipment-tracking-pro/

🏗️ Documentation in progress 🏗️