WooCommerce Integration
WooCommerce Integration
The solution uses the WooCommerce webhook to create sales orders in ERPNext for the orders placed through WooCommerce.
If the Customer or Item is absent in ERPNext while making a sales order from WooCommerce, the system will construct a new Customer or Item using the appropriate information from the WooCommerce order data. Also, using the delivery information from the order data, it produces an Address associated to the Customer.
1. How to set up WooCommerce?
1.1 Generate API Key and API Secret
- Click Settings from the sidebar of your WooCommerce website.
- Select the REST API link after selecting the "Advanced" option.
- Choose "Add key" from the menu. Provide the required information, then press the "Generate API key" button.
1.2 Woocommerce Settings
- Go to Home > Integrations > Settings > Woocommerce Settings on your ERPNext website.
- The "API consumer key" and "API consumer secret" fields should now contain the API key and secret that were produced in the previous step.
- In the "Woocommerce Server URL" paste the url of your WooCommerce site.
- Verify that "Enable Sync" is selected.
- On the Account Details Section, choose "Tax Account" and "Freight and Forwarding Account".
- Choose "Creation User" under the Defaults heading. To create Clients, Items, and Sales Orders, utilize this user. Make that the user has the necessary rights.
- Choose the "Company" to be used for generating sales orders.
- Click Save.
- The terms "Secret" and "Endpoint" are generated automatically after saving the Woocommerce Configuration.
1.3 Woocommerce Webhook Settings
- Go to Settings from the sidebar of your woocommerce website.
- Choose the "Advanced" tab, then select the Webhooks link and "Add webhook" from the menu.
- Choose an appropriate name for the webhook.
- Click on Status dropdown and select "Active".
- Choose "Order created" as the Subject.
- On your ERPNext site, copy the "Endpoint" from the "Woocommerce Settings" doctype and paste it in the "Delivery URL" column.
- In the "Secret" box of your ERPNext site, copy "Secret" from the "Woocommerce Settings" doctype.
- Maintain the current API VERSION and select Save Webhook. It has now been successfully set up.
Below is a GIF illustrating the full procedure:
Note: You must substitute the URL you will receive after saving the "Woocommerce Settings" in your ERPNext instance for the delivery url on the woocommerce website in the above screenshot and GIF's "Endpoint" field. As localhost was being used, another URL was inserted here.
1.4 Woocommerce order creation and syncing
- Sign up as a user on the Account page of your Woocommerce website.
- Next, select the Addresses option and provide the necessary information.
- Choose "Shop" from the menu, and the available products will be displayed.
- Fill your cart with the desired items and click See Cart.
- Click "Proceed to Checkout" from the cart once the desired items have been added.
- You may now access all billing information and order information. Once you're satisfied with it, select Place Order.
- "Order Received" message can been seen suggesting that the order has been placed successfully.
- Next up, ERP Next, look at the Client, Address, Item, and Sales Order document types. The webhook data will be fetched and used to generate them.
- You can verify the error in Home > Settings > Core > Error Log if the orders are not synced.
2. Features
2.1 Defaults
Woocommerce Settings DocType:
- Warehouse: Sales orders will be created using this warehouse. "Stores" is the default warehouse.
- Delivery After (Days): This is the delivery date's default offset (in days) in sales orders. Seven days after the order placing date is the default offset.
- You can designate a different series for sales orders generated by woocommerce. The "SO-WOO-" series is the default.
- UOM: For items and sales orders, this is the standard UOM. The UOM is "Nos" by default.