Script and GitHub Actions workflow to import products and collections from WooCommerce to Shopify.
You must download and activate the Node.js version specified here.
Clone the repository or use it as a template:
gh repo clone gabrielecanepa/woocommerce-to-shopify
# or
git clone https://github.com/gabrielecanepa/woocommerce-to-shopify.git
Activate pnpm using Corepack, install the dependencies and build the project:
corepack enable
corepack install
pnpm install
pnpm build
Copy the .env.example
file to .env
and fill in the necessary environment variables.
You can generate the Shopify access token by creating a private app in your Shopify store.
The WooCommerce consumer key and secret can be generated by creating a REST API key in your WordPress dashboard.
Run the script with either:
# Production mode
pnpm sync
# Development mode (with tsx)
pnpm sync:dev
To run the sync
workflow, you need to set the following in your GitHub Actions repository settings.
Secrets:
SHOPIFY_ACCESS_TOKEN
WOOCOMMERCE_CONSUMER_KEY
WOOCOMMERCE_CONSUMER_SECRET
Variables:
SHOPIFY_SHOP_NAME
WOOCOMMERCE_URL
The workflow is configured to run every 5 minutes (GitHub's limit for scheduled workflows) and can be triggered in one of the following ways.
-
With a
workflow_dispatch
event -
With a
repository_dispatch
event via the GitHub API:curl --request POST \ --url 'https://api.github.com/repos/<repo>/dispatches' \ --header 'authorization: Bearer <GITHUB_ACCESS_TOKEN>' \ --data '{ "event_type": "sync" }'