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).
- PHP 7.4 or above
⚠️ Secure credentials file (instructions for NGINX provided below)
- 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
- 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.
-
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.
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.
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.
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.
Important
With NGINX, securing this file requires additional steps, otherwise, anyone can access the file.
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;
}