# Shop Sync for WooCommerce — Installation Guide

## Overview

Shop Sync for WooCommerce syncs products, categories, and brands between multiple
WooCommerce websites. One website is the **source site** (where you manage your product
catalog), and one or more other websites are **destination sites** (which receive the
products).

This guide applies to both the **Lite** and **Pro** versions. Differences between the
versions are noted where relevant.

---

## Installation

### Step 1 – Install the plugin

Upload and activate the plugin via **Plugins → Add New** on:
- The **source site** (where you manage products) — required
- Destination sites — **not required**, but recommended for optimal brand synchronization

> The plugin also works without being installed on the destination site. Products,
> categories, and brands are then synced via the standard WooCommerce REST API. Install
> the plugin there too for direct brand taxonomy linking and extra protection logic.

### Step 2 – Set the role

Go to **Shop Sync** in the WordPress menu. On first installation, the plugin explicitly
asks whether this site is the source site or a destination site — no assumption is made
based on the domain.

### Step 3 – Configuration on the destination site

1. Go to **WooCommerce → Settings → Advanced → REST API**
2. Create a new key with **Read/Write** permissions
3. Note down the **Consumer Key** and **Consumer Secret**

### Step 4 – Add a website on the source site

1. Go to **Shop Sync → Websites**
2. Click **Add website**
3. Enter the URL and keys of the destination site
4. Select the categories that should be synced to this website
5. Test the connection and save

---

## Lite versus Pro

| Feature | Lite | Pro |
|---|---|---|
| Number of products to sync | Up to 50 | Unlimited |
| Number of destination sites | 1 | Unlimited |
| Sync interval | Manual | Automatic, configurable |
| AI descriptions (OpenAI) | Not available | Included |
| Category & brand sync | Basic | Full, with cache validation |
| Support | Email | Priority |

When the product limit is reached in the Lite version, the plugin shows a clear notice
with a link to upgrade to Pro. Products already synced keep working; only new products
beyond the limit are skipped until you upgrade or free up room.

---

## How it works

| Component | Description |
|-----------|-------------|
| **Sync interval** *(Pro)* | Configurable: 15 min / 30 min / hourly / twice daily / daily |
| **Fields** | All WooCommerce fields: name, description, images, price, stock, weight, dimensions, categories, attributes, variations |
| **Supplier marking** | Every synced product gets a `supplier` meta field with a unique ID pointing to the source site |
| **Destination site protection** | Products not created by this plugin are never modified or deleted by synchronization |
| **AI descriptions** *(Pro)* | Optional: rewrite descriptions via OpenAI before syncing, with caching per product and category |
| **Sync log** | All actions are logged under the **Sync log** tab |
| **Background queue** | Synchronization runs via a queue system with automatic retry on temporary server errors |

---

## Identifying source vs. destination site

The role is set explicitly via the admin page and stored in the database — no assumption
is made based on the domain. For developers, a manual override via `wp-config.php` is
available:

```php
// Source site:
define( 'SC_SYNC_IS_SOURCE', true );

// Destination site:
define( 'SC_SYNC_IS_SOURCE', false );
```

---

## Technical details

- Uses the **WooCommerce REST API** (`wc/v3/products`) for product communication
- Authentication via **Basic Auth** (Consumer Key + Secret)
- Variations are synced separately via `wc/v3/products/{id}/variations`
- Remote product IDs are stored as WordPress post meta
- Background processing via WP-Cron and a queue runner with automatic retry on
  HTTP 401/403/429/5xx status codes
- The supplier ID per source site is automatically derived from the domain, but configurable

---

## Requirements

- WordPress 6.0+
- WooCommerce 7.0+
- PHP 7.4+
- HTTPS on the destination site (recommended for secure API communication)
