=== StoreSheet – Google Sheets Sync for WooCommerce ===
Contributors: mralaminahamed
Donate link: https://alaminahamed.com/donate
Tags: woocommerce, google-sheets, sync, spreadsheet, inventory
Requires at least: 6.6
Tested up to: 7.0
Requires PHP: 7.4
Stable tag: 1.0.0
License: GPL-2.0-or-later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Automatically sync your WooCommerce products, orders, and coupons to a Google Spreadsheet. One-way (WC → Sheets), OAuth-secured, non-blocking.

== Description ==

StoreSheet copies your WooCommerce products, orders, and coupons into a Google Spreadsheet and keeps them current. The work happens in the background on WordPress's own task scheduler, so it doesn't hold up the checkout or the admin.

The free version syncs one way: WooCommerce to Google Sheets. Once the data is in a sheet, you can build reports on it or hand a copy to someone who doesn't have a WordPress login.

What it does:

* Syncs every product, order, and coupon into a Google Spreadsheet, both as they change and on a schedule.
* Leaves the Overview and Reports tabs open for your own Sheets formulas, so you can put revenue totals or margin math wherever you want them.
* Connects through Google OAuth 2.0. Your client secret stays on your server and is never sent to the browser.
* Lets you pick which order statuses and which data types get synced.
* Emails you, or pings a Slack channel, when a sync job fails for good.

How it works:

1. You connect a Google account with OAuth 2.0. The credentials stay on your server.
2. StoreSheet creates a spreadsheet with tabs for Products, Orders, Coupons, Overview, and Reports. (The Variations and Customers tabs are laid out but only filled in by StoreSheet Pro.)
3. When a WooCommerce event fires — a new order, a product edit, a new coupon — StoreSheet queues a job through Action Scheduler that writes that one row to the sheet.
4. A scheduled run (every 15 minutes by default) picks up anything the live jobs missed. Because it all runs on Action Scheduler in the background, the store keeps responding normally.

**Sync coverage (free):**

* **Products** — synced WooCommerce → Sheets.
* **Orders** — synced WooCommerce → Sheets (choose which statuses).
* **Coupons** — synced WooCommerce → Sheets.
* **Overview** — formula dashboard tab, left open for your own Sheets formulas.
* **Reports** — formula analytics tab, left open for your own Sheets formulas.

If a job fails for good, StoreSheet emails the site admin and, if you set one up, posts to a Slack webhook so you're not left guessing.

== StoreSheet Pro ==

StoreSheet Pro is a separate add-on. It adds the reverse direction and a few heavier features:

* Two-way sync. Edit a product's price, stock, status, or a coupon straight in the sheet and StoreSheet pushes the change back to WooCommerce. A small Google Apps Script sends the edit over an HMAC-signed webhook, and it only fires on manual edits, so the plugin's own writes don't loop back on themselves.
* Variations and Customers sync, which fill in the two tabs the free version leaves empty.
* Bulk backfill. One click loads your whole existing catalog into the sheet in chunks small enough to avoid timeouts.
* Conflict resolution. Decide who wins when both sides changed: Sheets, WooCommerce, or whichever was edited last.
* Dokan vendor sheets for multi-vendor stores.

The Plans tab inside the plugin has the details.

== Installation ==

1. Upload the plugin folder to `/wp-content/plugins/` or install via **Plugins → Add New**.
2. Activate the plugin (WooCommerce must be installed and active).
3. Go to **StoreSheet**.
4. On the **Connect** tab, enter your Google OAuth credentials and click **Authorize**.
5. On the **Connect** tab, click **Create Spreadsheet** — StoreSheet builds the full sheet structure.
6. Open the **Sync** tab to choose your interval, order statuses, and data types. Your WooCommerce data begins flowing into the spreadsheet.

== Frequently Asked Questions ==

= Does this plugin store my Google credentials? =

Your OAuth refresh token is stored in the WordPress options table (encrypted at rest if you use a security plugin that encrypts options). The client secret is never sent to the browser.

= Can I edit a cell in Google Sheets and have it update WooCommerce? =

No, not in the free version. The free build only syncs one way, WooCommerce to Sheets. Editing in the sheet and having it push back to WooCommerce is a StoreSheet Pro feature that runs over a signed Apps Script webhook.

= How often does WooCommerce sync to Sheets? =

Individual changes go across in real time (a new order, a saved product, a new coupon). On top of that, a scheduled run every 15 minutes by default sweeps up anything the live jobs missed. You can change that interval on the Sync tab.

= What happens if the Google Sheets API is down? =

Action Scheduler retries the failed jobs. If they still fail after the last attempt, StoreSheet emails the admin (when notifications are on). Your store keeps running either way, since the sync never blocks a WooCommerce request.

= Can I import my whole existing catalog at once? =

New changes sync on their own, and the scheduled run keeps the sheet current from there. Loading a large existing catalog in one go (in chunks small enough not to time out) is the bulk backfill in StoreSheet Pro.

= Does it work with Dokan vendors? =

Per-vendor sheets for Dokan stores come with the StoreSheet Pro add-on.

== Screenshots ==

1. Overview dashboard — live sync counts and recent activity log.
2. Connect tab — Google OAuth and spreadsheet setup.
3. Sheets tab — per-tab column map.
4. Sync settings — direction, interval, order statuses, and data types.
5. The auto-generated Google Spreadsheet with all tabs.

== Changelog ==

= 1.0.0 =
* Initial release.
* One-way WooCommerce → Google Sheets sync for Products, Orders, and Coupons.
* Google OAuth 2.0 connection with automatic access-token refresh.
* Real-time (WooCommerce event) and scheduled sync via Action Scheduler.
* Overview and Reports formula tabs.
* Admin email and Slack failure notifications.

== Third-Party Plugins ==

StoreSheet extends WooCommerce and requires it to function. No data is sent to third-party plugin developers by StoreSheet itself.

= WooCommerce (required) =

Provides the products, orders, and coupons that StoreSheet syncs, the event hooks it reacts to (e.g. `woocommerce_update_product`, `woocommerce_checkout_order_created`, `woocommerce_new_coupon`), and the logging channel used for sync traces. WooCommerce 3.0+ must be installed and active.

* Plugin: [WooCommerce](https://wordpress.org/plugins/woocommerce/)
* Developer: [WooCommerce](https://woocommerce.com/)

== External Services ==

This plugin connects to external services only when explicitly configured by the site administrator.

= Google OAuth & Sheets API =

When you connect your Google account, the plugin communicates with the following Google endpoints to authorise access and read/write spreadsheet data:

* OAuth authorisation: https://accounts.google.com/o/oauth2/v2/auth
* Token exchange and refresh: https://oauth2.googleapis.com/token
* Token revocation: https://oauth2.googleapis.com/revoke
* User info (display name and email for the connected account): https://www.googleapis.com/oauth2/v3/userinfo
* Sheets API (read and write spreadsheet data): https://sheets.googleapis.com/v4/spreadsheets/

Data sent includes the WooCommerce product, order, and coupon data you have chosen to sync. No data is sent before OAuth is completed and a spreadsheet is selected.

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

= WordPress.org Plugin Directory (admin only) =

The Plans page optionally fetches a list of the plugin author's other plugins from the WordPress.org API to display in the admin dashboard. This request is made only when a logged-in administrator views that page. No site data is sent.

* API: https://api.wordpress.org/plugins/info/1.2/
* Privacy Policy: https://automattic.com/privacy/

= Slack (optional) =

If the Slack notification integration is enabled and a webhook URL is configured, the plugin posts a summary message to that URL when a sync job fails. No data is sent unless a webhook URL is saved and the integration is active.

* Service: [Slack](https://slack.com/)
* Terms of Service: https://slack.com/terms-of-service
* Privacy Policy: https://slack.com/privacy-policy

= Freemius (licensing & product analytics, opt-in) =

This plugin uses the Freemius service to power upgrades to the StoreSheet Pro add-on and, if you consent, anonymous usage diagnostics that help improve the plugin. Freemius runs on an explicit opt-in: on activation you are shown a permissions screen and can **skip** it. No data is sent to Freemius unless you opt in or you activate a Pro license.

When enabled, data sent may include: site URL, WordPress and PHP versions, the administrator email address, active plugin/theme information, and StoreSheet version. This is used for license validation, update delivery, and product analytics.

* Service: [Freemius](https://freemius.com/)
* Terms of Service: https://freemius.com/terms/
* Privacy Policy: https://freemius.com/privacy/

== Privacy ==

This plugin transmits WooCommerce store data (products, orders, and coupons) to Google Sheets only when Google OAuth is completed and sync is enabled. Data is limited to what you have explicitly chosen to sync. OAuth tokens are stored in the WordPress options table on your own server and are never exposed to the browser. No data is transmitted to any external service before you connect your Google account.

== Upgrade Notice ==

= 1.0.0 =
Initial release. No upgrade steps required.
