WooCommerce connector for Tryton

As discussed on Minimal e-shop for Tryton it makes sense to have a web frontend for selling Tryton. II think it makes sense to be able to have some connectors for people that already have a webshop and they want to sync it with Tryton. I think we should develop one for WooCommerce, as it’s been widely used nowadays. This connector will reuse the the web_shop module from the minimal webshopt but create a new module (web_shop_woocommerce) to sync data with woocommerce.

The WooCommerce REST API can be used to retrieve and push data to WooCommerce. There is an available Python Wrapper for it, so It makes sense to us it.

Using this wrapper we can create the following cron jobs:

  • Export products data to WooCommerce
  • Sync products stock with WooCommerce
  • Import Customer Orders from WooCommerce: Download customer orders and it’s related data from woocommerce to Tryton.

There are several order states on WooCommerce so once the order progress on Tryton, we should upate the states back to woocoomerce so the customer knows that he’s order has been updated.

  • Pending Payment and On-Hold orders should be on Tryton’s Quotation
  • Processing order should be on Tryton’s Processing state.
  • Once the shipment is sent, the order should be in *Completed" woocommerce state.

I think this should be the default behaviour of Tryton but It should be configurable per Tryton shop. So I propose to store the WooCommerce state field on the Sale and allow the developer to customize the state. A task in the queue should be responsible to sync the WooCommerce state with the webshop.

1 Like

I think this part should be very configurable because for example some will manage stock in WooCommerce, others not etc.

I do not think it is needed to have a order stats synchronization. We can only create completed order in Tryton and deal with the refund state.

I do not think WooCommerce order workflow is really configurable.

But the biggest difficulties are the taxes, the party two-way synchronization and the stock management.

I already did such development for a customer and the WooCommerce API is not really good for synchronization. You mainly have to loop over all records. Or you can store the last sync ID and loop until reaching this ID.

I do not think we need to do two-way party sincronization. For me we can try to find existing parties by it’s tax_identifier or email.

Then the parties can be merged back using the merge wizard.

If somebody is interested on it we published an implementation of the woocomerce connector:

This is not perfect but it is used for one of our customers to sync 23k of products and download the woocommerce orders.

Feel free to review, test and leave any comment on it :hugs:

1 Like

Hey, great you came that far so quickly! - I’d be very happy to test it under “real” conditions - could there be minimal advice how to install and use it?

My destruction potential of guessing is high…

Cheers,
Wolf

You just need to download the module and activate it on a database.

If you are using docker, you can create a Dockerfile with the following content:

FROM tryton/tryton:$SERIES as builder
USER root
WORKDIR /
RUN apt-get update \
    && apt-get install -y --no-install-recommends \
        git \
    && rm -rf /var/lib/apt/lists/*
RUN git clone https://gitlab.com/kopen/web_shop_woocommerce \
    && cd web_shop_woocommerce \
    && python3 setup.py sdist


FROM tryton/tryton:$SERIES
USER root
COPY --from=builder /web_shop_woocommerce/dist /dist
RUN pip3 install --no-cache-dir --install-option="-O1" \
        /dist/* \
    && rm -rf /root/.cache /dist/
USER trytond

Please update $SERIES with the series you are running from.

Then you can run this with:

docker build . -t trytond_woocommerce
docker run trytond_woocommerce

1 Like