Skip to content

Script and GitHub Actions workflow to programmatically import products and collections from WooCommerce to Shopify 🗘

License

Notifications You must be signed in to change notification settings

gabrielecanepa/woocommerce-to-shopify

Repository files navigation

WooCommerce to Shopify


Script and GitHub Actions workflow to import products and collections from WooCommerce to Shopify.

Prerequisites

You must download and activate the Node.js version specified here.

Setup

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

Environment variables

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.

Running the script

Locally

Run the script with either:

# Production mode
pnpm sync
# Development mode (with tsx)
pnpm sync:dev

GitHub Actions

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" }'

About

Script and GitHub Actions workflow to programmatically import products and collections from WooCommerce to Shopify 🗘

Topics

Resources

License

Stars

Watchers

Forks