Skip to content

A simple plugin to automatically send your WooCommerce store orders to a Google Sheet. While it's not the most user-friendly solution, it can help you get started quickly if you're building a similar custom solution.

License

Notifications You must be signed in to change notification settings

Babylon1999/woocommerce-google-sheets-integration

Repository files navigation

WooCommerce Google Sheets Integration

A simple plugin to automatically send your WooCommerce store orders to a Google Sheet. There's no JS, no css, no settings page, just a single php file (less than 110 lines of code).

Requirements

  • PHP 7.4 or above
  • ⚠️ Secure credentials file (instructions for NGINX provided below)

Setup Instructions

1. Create a Google Sheet

  • Create a Google Sheet with the following headers:

order date | order id | order total | total fees | total shipping tax | shipping total | order subtotal | total discount

  • In the Google Sheet URL, locate and save the sheet ID, which looks something like this: image1

2. Clone the Repository

  • Clone the repository locally and navigate to the project directory.
  • Run composer install to install the Google API library. By default version 2.0.3 will be installed because it's compatible with PHP 7.4, if you're using PHP 8.1 or above, feel free to install another version.

3. Configure the Plugin

  • Open the main plugin file.

  • Replace 'your_sheet_id' with the sheet ID you saved from the Sheet URL.

  • Update the $sheet_name if needed, which you can find at the bottom of your Google Sheet.

  • image

4. Authenticate Using a Service Account

Authenticating with Google services can be a bit of a maze, luckily there are plenty of online resources to guide you through the process. Here's a quick summary:

  • Enable the Google Sheets API from your Google Cloud project.
  • Navigate to Credentials -> Create Service Account.

Service Account Creation

  • Download a JSON key file and save it as creds.json in the plugin directory.

  • image

5. Secure the Credentials File (Crucial Step)

The JSON file containing your service account credentials holds the keys to your account. If someone gains access to it, they essentially have control over your account. Therefore, it's paramount to ensure this file can't be accessed directly.

Apache Server

If you're using Apache, you don't have to worry about this too much, I already added a .htaccess file in place to prevent all access to the plugin files.

NGINX Server

Important

With NGINX, securing this file requires additional steps, otherwise, anyone can access the file.

NGINX Vulnerability

To address this, add this to your config file and restart the server. Make sure to try and access the file after doing so to make sure it's working as expected.

	location /wp-content/plugins/woocommerce-google-sheets-integration/ {
    deny all;
    return 404;
}

About

A simple plugin to automatically send your WooCommerce store orders to a Google Sheet. While it's not the most user-friendly solution, it can help you get started quickly if you're building a similar custom solution.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages