Woocommerce Connector sync failure

Hi everyone,

Would someone be able to point me in the correct direction with regard this error on woocommerce connector. Below is the error, am i right in thinking i need to add discount “something” into the database? Or what is it looking for?

raceback (most recent call last):
File “apps/woocommerceconnector/woocommerceconnector/sync_orders.py”, line 30, in sync_woocommerce_orders
create_order(woocommerce_order, woocommerce_settings)
File “apps/woocommerceconnector/woocommerceconnector/sync_orders.py”, line 164, in create_order
so = create_sales_order(woocommerce_order, woocommerce_settings, company)
File “apps/woocommerceconnector/woocommerceconnector/sync_orders.py”, line 211, in create_sales_order
“taxes”: get_order_taxes(woocommerce_order, woocommerce_settings),
File “apps/woocommerceconnector/woocommerceconnector/sync_orders.py”, line 378, in get_order_taxes
taxes = update_taxes_with_shipping_lines(taxes, woocommerce_order.get(“shipping_lines”), woocommerce_settings)
File “apps/woocommerceconnector/woocommerceconnector/sync_orders.py”, line 399, in update_taxes_with_shipping_lines
“account_head”: get_shipping_account_head(shipping_charge),
File “apps/woocommerceconnector/woocommerceconnector/sync_orders.py”, line 412, in get_shipping_account_head
shipping_account = frappe.db.get_value(“woocommerce Tax Account”,
File “apps/frappe/frappe/database/database.py”, line 472, in get_value
result = self.get_values(
File “apps/frappe/frappe/database/database.py”, line 569, in get_values
out = self._get_values_from_table(
File “apps/frappe/frappe/database/database.py”, line 799, in _get_values_from_table
return self.sql(query, as_dict=as_dict, debug=debug, update=update, run=run, pluck=pluck)
File “apps/frappe/frappe/database/database.py”, line 206, in sql
self._cursor.execute(query, values)
File “env/lib/python3.10/site-packages/pymysql/cursors.py”, line 148, in execute
result = self._query(query)
File “env/lib/python3.10/site-packages/pymysql/cursors.py”, line 310, in _query
File “env/lib/python3.10/site-packages/pymysql/connections.py”, line 548, in query
self._affected_rows = self._read_query_result(unbuffered=unbuffered)
File “env/lib/python3.10/site-packages/pymysql/connections.py”, line 775, in _read_query_result
File “env/lib/python3.10/site-packages/pymysql/connections.py”, line 1156, in read
first_packet = self.connection._read_packet()
File “env/lib/python3.10/site-packages/pymysql/connections.py”, line 725, in _read_packet
File “env/lib/python3.10/site-packages/pymysql/protocol.py”, line 221, in raise_for_error
File “env/lib/python3.10/site-packages/pymysql/err.py”, line 143, in raise_mysql_exception
raise errorclass(errno, errval)
pymysql.err.ProgrammingError: (1064, “You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ‘b’Discount’ ORDER BY modified DESC LIMIT 1’ at line 1”)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “apps/woocommerceconnector/woocommerceconnector/api.py”, line 52, in sync_woocommerce_resources
File “apps/woocommerceconnector/woocommerceconnector/sync_orders.py”, line 15, in sync_orders
File “apps/woocommerceconnector/woocommerceconnector/sync_orders.py”, line 37, in sync_woocommerce_orders
if e.args and e.args[0] and e.args[0].decode(“utf-8”).startswith(“402”):
AttributeError: ‘int’ object has no attribute ‘decode’

Thanking you all.

Hello, you have to remove this part decode(“utf-8”). in the doctype sync_orders.py to make it work without any problem.

1 Like

Hi, I did, but it then fails on AttributeError: ‘int’ object has no attribute startswith. If i remove .startswith(“402”), then it fails on DB syntax error. But i have come to the conclusion it has to do with the version of ERPnext as this error only occurs on V14. And Woocommerce connector isn’t supported on V14.

Thanks for the reply.

I am using version-14 and I have no inconvenience
You can open the sync_orders.py file and send me a screenshot of the text where you deleted what I indicated.
The .startswith(“402”) should not be deleted.

Hi see below

Add the code below in bold, this is what is needed.

make_woocommerce_log(title=e.message if hasattr(e, ‘message’)else str(e), status=“Error”, method=“sync_woocommerce_orders”, message=frappe.get_traceback(),
request_data=woocommerce_order, exception=True)

Thank you so much for the help, but i now get this

Failed to get method for command woocommerceconnector.api.get_log_status with (unicode error) ‘utf-8’ codec can’t decode byte 0x91 in position 0: invalid start byte (sync_orders.py, line 40)

In the box on the page.

I assume i have copied and pasted syntax wrong.

copy the code I sent you and replace it in your file

I did as per the image

As I see it, it is 2 spaces before ‘if hasattr’

I’m seeing the same first part of the traceback referring to
pymysql.err.ProgrammingError: (1064, …

I can’t seem to get to the bottom of the problem.

@Leo_Sarmiento I wonder did you upgrade or install woocommerce to a new version 14 install?

Hi, I have done several installations from scratch of the woocommerce connector in Erpnext v14.

great … Do you have a fork on Github that can be used to get it working?

I do not have a connector fork

i had the same error, i have copied the code in bold, now it doesn’t create any log entry in woocommerce log list. i can not understand if sync works or not. (erpnext v14 )

The problem when copying is the quotation marks that are changed.

If it is compatible, I tested it on a test system ERPNEXT v14.29.1 and the Woocommerce connector Libracore for synchronization of variants, everything is functional the only error I found so far is something related to Ecuador taxes and the version of MariaDB when synchronizing the order I’m reviewing and images in ERPNEXT that I must add the correct URL.