Woocommerce full 2 way integration

In case this is of interest, we have now strongly improved the “Error 400: Bad Request” from WooCommerce with the latest release of the WooCommerceConnector. It will now show a detailed error, which helps to solve issues (e.g. invalid item codes…)

@lasalesi thanks for your continued support and development of this app for the community. sincerely wish that it can be integrated into core…

I had remainder question from before - when order is placed and paid using credit card in woocommerce - what is synced in erpnext? assuming order is created with same items and prices? You had mentioned earlier that a sales invoice is created as well with “is_paid” checkmarked? are the credit card payment details / confirmation number / other payment mechanism payment details captured in erp? to which bank account?

Appreciate your clarifications. Thanks.

Hi,

Today I configured the sync between ERPNext and Woocommerce with this integration.

The sync is running, I got some products and customers but then I receive [Task exceeded maximum timeout value (1500 seconds) ](http://erp.hbit.nl:8000/desk#Form/woocommerce Log/407857bd90)

Where can I increase the timeout? This is pretty low for an initial sync.

Hi @zerodiscount,

thanks for your feedback. To get a detailed answer, you can always check out sync_orders.py

Item positions with their actual sales price in WooCommerce (might differ from price list rate due to discounts) are imported. Importing sales invoice and payment are options that you can enable in the WooCommerce Config. The bank account is set a bit higher up under cash/bank account.

Hope this helps.

Hi @Hbitvof,

thanks for your feedback. Normally, that will actually be sufficient, but I understand that for an initial sync this might be rather short… I have just created a configurable field for the sync timeout in the latest version, maybe you can give it a try…

1 Like

Hi @lasalesi,

What a quick change, awesome.

When updating now I get:

Compiling Python Files…
*** Error compiling ‘…/apps/woocommerceconnector/woocommerceconnector/api.py’…
Sorry: IndentationError: unindent does not match any outer indentation level (api.py, line 24)

I see the new setting in the woocommerce setting but I get :

image

is there a way to sync old orders, like a month ago or so ?

Hi @Hbitvof,

thanks for the note, there was just a hotfix to resolve this. Sorry for the inconvenience! Can you please update and try again?

Hi @fBazaar_Support,

thanks for your message. Orders are only imported if they are on status “processing” in WooCommerce (independent of their age). If you want to import completed orders, you would have to add this as a feature (or change the trigger and run the import with a modified import filter)

i tried to change completed order status to processing, but as you may guess, nothing has happened…
since i am so far from being a coder, can you show me a way of this step by step how to change the trigger ?
I am sure it will be very useful to everybody who needs order sync.
thank you

If you look at this file:

you will find on line 22

if woocommerce_order.get("status").lower() == "processing":

which only processes pending orders. If you temporarity switch this to

if True:

it will process all orders.

1 Like

thank you very much, it was useful !

I’m having problems installing this with the following error:

In [1]: from frappe.installer import install_app

In [2]: install_app('woocommerceconnector')

Installing woocommerceconnector...
---------------------------------------------------------------------------
IntegrityError                            Traceback (most recent call last)
~/frappe-bench/commands/console.py in <module>
----> 1 install_app('woocommerceconnector')

~/frappe-bench/apps/frappe/frappe/installer.py in install_app(name, verbose, set_as_patched)
     80 
     81 	if name != "frappe":
---> 82 		add_module_defs(name)
     83 
     84 	sync_for(name, force=True, sync_everything=True, verbose=verbose, reset_permissions=True)

~/frappe-bench/apps/frappe/frappe/installer.py in add_module_defs(app)
    303 		d.app_name = app
    304 		d.module_name = module
--> 305 		d.save(ignore_permissions=True)
    306 
    307 def remove_missing_apps():

~/frappe-bench/apps/frappe/frappe/model/document.py in save(self, *args, **kwargs)
    279 	def save(self, *args, **kwargs):
    280 		"""Wrapper for _save"""
--> 281 		return self._save(*args, **kwargs)
    282 
    283 	def _save(self, ignore_permissions=None, ignore_version=None):

~/frappe-bench/apps/frappe/frappe/model/document.py in _save(self, ignore_permissions, ignore_version)
    301 
    302 		if self.get("__islocal") or not self.get("name"):
--> 303 			self.insert()
    304 			return
    305 

~/frappe-bench/apps/frappe/frappe/model/document.py in insert(self, ignore_permissions, ignore_links, ignore_if_duplicate, ignore_mandatory, set_name, set_child_names)
    244 		else:
    245 			try:
--> 246 				self.db_insert()
    247 			except frappe.DuplicateEntryError as e:
    248 				if not ignore_if_duplicate:

~/frappe-bench/apps/frappe/frappe/model/base_document.py in db_insert(self)
    326 					columns = ", ".join(["`"+c+"`" for c in columns]),
    327 					values = ", ".join(["%s"] * len(columns))
--> 328 				), list(d.values()))
    329 		except Exception as e:
    330 			if frappe.db.is_primary_key_violation(e):

~/frappe-bench/apps/frappe/frappe/database/database.py in sql(self, query, values, as_dict, as_list, formatted, debug, ignore_ddl, as_utf8, auto_commit, update, explain)
    156 					frappe.log(values)
    157 					frappe.log(">>>>")
--> 158 				self._cursor.execute(query, values)
    159 
    160 				if frappe.flags.in_migrate:

~/frappe-bench/env/lib/python3.7/site-packages/pymysql/cursors.py in execute(self, query, args)
    168         query = self.mogrify(query, args)
    169 
--> 170         result = self._query(query)
    171         self._executed = query
    172         return result

~/frappe-bench/env/lib/python3.7/site-packages/pymysql/cursors.py in _query(self, q)
    326         self._last_executed = q
    327         self._clear_result()
--> 328         conn.query(q)
    329         self._do_get_result()
    330         return self.rowcount

~/frappe-bench/env/lib/python3.7/site-packages/pymysql/connections.py in query(self, sql, unbuffered)
    515                 sql = sql.encode(self.encoding, 'surrogateescape')
    516         self._execute_command(COMMAND.COM_QUERY, sql)
--> 517         self._affected_rows = self._read_query_result(unbuffered=unbuffered)
    518         return self._affected_rows
    519 

~/frappe-bench/env/lib/python3.7/site-packages/pymysql/connections.py in _read_query_result(self, unbuffered)
    730         else:
    731             result = MySQLResult(self)
--> 732             result.read()
    733         self._result = result
    734         if result.server_status is not None:

~/frappe-bench/env/lib/python3.7/site-packages/pymysql/connections.py in read(self)
   1073     def read(self):
   1074         try:
-> 1075             first_packet = self.connection._read_packet()
   1076 
   1077             if first_packet.is_ok_packet():

~/frappe-bench/env/lib/python3.7/site-packages/pymysql/connections.py in _read_packet(self, packet_type)
    682 
    683         packet = packet_type(buff, self.encoding)
--> 684         packet.check_error()
    685         return packet
    686 

~/frappe-bench/env/lib/python3.7/site-packages/pymysql/protocol.py in check_error(self)
    218             errno = self.read_uint16()
    219             if DEBUG: print("errno =", errno)
--> 220             err.raise_mysql_exception(self._data)
    221 
    222     def dump(self):

~/frappe-bench/env/lib/python3.7/site-packages/pymysql/err.py in raise_mysql_exception(data)
    107         errval = data[3:].decode('utf-8', 'replace')
    108     errorclass = error_map.get(errno, InternalError)
--> 109     raise errorclass(errno, errval)

IntegrityError: (1048, "Column 'custom' cannot be null")

Any ideas?

Which version of ERPNext are you installing to? Is there an advantage of installing from bench console rather than normal bench command?

Hi community, I am experiencing the sync issue. I posted on the github page with no replies so that’s why I am asking here.

I did a fresh install of both frappe (v12.11.0) and ERPNext (v12.13.0) and created products in ERPNext for sync to a blank woocommerce store. I then installed WooCommerce Connector 1.6.0 and set up the required settings, the products for some reason don’t sync to the woocommerce store. I get a blank response when syncing stating 0 customers, 0 items and 0 orders synced.

I have enabled a few products for sync in their items page to woocommerce, one simple product and one variable product, however nothing is synced across to woocommerce when I push the “Sync Woocommerce” button.

Maybe I am missing something in the settings of either ERPNext or WoocommerceConnector?

Hi,

I would like to grant a project to someone who can do 2 way woo commerce integration for me.

because I am fed up with this trial and error methods and finally not success.

Much appreciate your support.

I can do this for you. Please let me know.

Hello Man,

I message you on the telegram group of ERPNext Devs Public about my challenge with configuring this app, and you said I should message you here. See the attached screenshot of the error and its traceback.

VM1426:1 POST https://** .com/api/method/frappe.desk.form.save.savedocs 500 (INTERNAL SERVER ERROR)
(anonymous) @ VM1426:1
send @ jquery.min.js:4
ajax @ jquery.min.js:4
frappe.request.call @ request.js:220
frappe.call @ request.js:91
c @ save.js:204
frappe.ui.form.save @ save.js:25
(anonymous) @ form.js:626
Promise.then (async)
(anonymous) @ dom.js:265
frappe.run_serially @ dom.js:263
validate_and_save @ form.js:617
(anonymous) @ form.js:557
setTimeout (async)
(anonymous) @ form.js:556
save @ form.js:550
Save @ toolbar.js:450
(anonymous) @ page.js:171
dispatch @ jquery.min.js:3
r.handle @ jquery.min.js:3
request.js:356 Traceback (most recent call last):
File “/home/
/frappe-bench/apps/frappe/frappe/desk/form/save.py”, line 21, in savedocs
doc.save()
File “/home/
/frappe-bench/apps/frappe/frappe/model/document.py”, line 281, in save
return self._save(*args, kwargs)
File “/home/
/frappe-bench/apps/frappe/frappe/model/document.py”, line 316, in _save
self.run_before_save_methods()
File “/home/
/frappe-bench/apps/frappe/frappe/model/document.py”, line 926, in run_before_save_methods
self.run_method(“validate”)
File “/home/
/frappe-bench/apps/frappe/frappe/model/document.py”, line 827, in run_method
out = Document.hook(fn)(self, *args, kwargs)
File “/home/
/frappe-bench/apps/frappe/frappe/model/document.py”, line 1119, in composer
return composed(self, method, *args, kwargs)
File “/home/
/frappe-bench/apps/frappe/frappe/model/document.py”, line 1102, in runner
add_to_return_value(self, fn(self, *args, kwargs))
File “/home/
/frappe-bench/apps/frappe/frappe/model/document.py”, line 821, in
fn = lambda self, *args, kwargs: getattr(self, method)(*args, kwargs)
File “/home/
/frappe-bench/apps/woocommerceconnector/woocommerceconnector/woocommerceconnector/doctype/woocommerce_config/woocommerce_config.py”, line 17, in validate
self.validate_access()
File “/home/
/frappe-bench/apps/woocommerceconnector/woocommerceconnector/woocommerceconnector/doctype/woocommerce_config/woocommerce_config.py”, line 26, in validate_access
r = get_request(‘settings’, {“api_key”: self.api_key,
File “/home/
/frappe-bench/apps/woocommerceconnector/woocommerceconnector/woocommerce_requests.py”, line 61, in get_request
return get_request_request(path, settings).json()
File “/home/
****/frappe-bench/env/lib/python3.8/site-packages/requests/models.py”, line 898, in json
return complexjson.loads(self.text, **kwargs)
File “/usr/lib/python3.8/json/ init .py”, line 357, in loads
return _default_decoder.decode(s)
File “/usr/lib/python3.8/json/decoder.py”, line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File “/usr/lib/python3.8/json/decoder.py”, line 355, in raw_decode
raise JSONDecodeError(“Expecting value”, s, err.value) from None

woocommerce sync gets terminated.please help to solve this following errors

I think you error is related to the SSL verification. Do you have SSL verify on or off? The error trace shows that the validation of the connection fails…

1 Like