=== Pi SheetBridge for Woo order with Google Sheets ===
Contributors: rajeshsingh520
Donate link: https://piwebsolution.com
Tags: woocommerce, google sheets, order, connector, gsheet
Requires at least: 6.0
Tested up to: 7.0
License: GPLv2 or later
Stable tag: 1.3
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Auto send WooCommerce order data to Google Sheets. You can select the sheet and columns to send the order data.

== Description ==

Auto send WooCommerce order data to Google Sheets. You can select the sheet and columns to send the order data. You can select a different sheet for each product. You can also select the order status to trigger data export to Google Sheets.

== Installation ==

1. Upload the plugin files to the `/wp-content/plugins/pi-sheetbridge-for-woo-order-with-google-sheets/` directory, or install the plugin through the WordPress plugins screen directly.
2. Activate the plugin through the 'Plugins' screen in WordPress.
3. Go to WooCommerce > Pi WooCommerce Order Sync to Google Sheets settings page.
4. Follow the setup guide below to configure your Google Service Account credentials and sheet settings.

== External services ==

This plugin connects to Google Sheets API to automatically sync WooCommerce order and product data to Google Sheets. This connection is required for the plugin's core functionality.

**Service provider:** Google LLC (Google Sheets API)

**What data is sent:**
When an order status changes (configurable in plugin settings), the plugin transmits:
- Order data: order number, order date, order status, order total, billing/shipping addresses, customer information
- Product data: product names, SKUs, quantities, unit prices, totals, and any custom product meta fields configured by the user
- Custom meta fields: any custom order or product meta fields you have registered via the "Custom Meta Fields" settings tab

**When data is sent:**
- Automatically when an order transitions to a status selected in the plugin settings
- Data is only transmitted if you have configured a Google Sheet and provided valid Google Service Account credentials
- No data is sent if the plugin is not yet configured or if no order statuses have been selected for triggering

**Required setup:**
You must manually:
- Create a Google Cloud Project
- Enable Google Sheets API
- Create a Service Account with a JSON key
- Share your Google Sheet(s) with the service account email

**Service Terms & Privacy:**
- [Google API Terms of Service](https://cloud.google.com/terms)
- [Google Privacy Policy](https://policies.google.com/privacy)


== Setup Guide: Getting Google Service Account JSON ==

= Step 1: Create a Google Cloud Project =

1. Go to [Google Cloud Console](https://console.cloud.google.com/)
2. Sign in with your Google account
3. Click the **Project selector** (top-left, next to "Google Cloud")
4. Click **New Project**
5. Enter a project name (e.g., "WordPress Sheets Sync")
6. Click **Create**
7. Wait for the project to be created (may take a minute)

= Step 2: Enable the Google Sheets API =

1. In the Google Cloud Console, go to **APIs & Services** > **Library**
2. Search for **"Google Sheets API"**
3. Click on **Google Sheets API**
4. Click **Enable**
5. Wait for it to finish enabling

= Step 3: Create a Service Account =

1. Go to **APIs & Services** > **Credentials**
2. Click **Create Credentials** (top button)
3. Select **Service Account**
4. Fill in:
   - **Service account name:** e.g., `wordpress-sheets`
   - **Service account ID:** (auto-fills, leave as-is)
   - **Description:** (optional) e.g., `For WordPress Google Sheets sync`
5. Click **Create and Continue**
6. On the next screen, click **Continue** (skip the optional steps)
7. Click **Done**

= Step 4: Create a JSON Key =

1. In **APIs & Services** > **Credentials**, find your newly created service account in the **Service Accounts** section
2. Click on the service account name
3. Go to the **Keys** tab
4. Click **Add Key** > **Create new key**
5. Select **JSON** format
6. Click **Create**
7. A `.json` file will download to your computer automatically

= Step 5: Copy the JSON Content =

1. Open the downloaded `.json` file with a text editor (Notepad, VS Code, etc.)
2. Select **all the content** (Ctrl+A or Cmd+A)
3. Copy it (Ctrl+C or Cmd+C)
4. In your WordPress plugin settings, paste it into the **Google Service Account JSON** textarea field

= Step 6: Share Your Google Sheet with the Service Account =

1. Look inside the JSON file for the **`"client_email"`** field (looks like `xxxx@xxxx.iam.gserviceaccount.com`)
2. Copy that email address
3. Open the Google Sheet you want to sync with
4. Click **Share** (top-right)
5. Paste the service account email
6. Give it **Editor** access
7. Click **Share**

