# BookPod Author Tools

**BookPod Author Tools** is a WordPress plugin designed to seamlessly integrate WooCommerce stores with the BookPod system. It streamlines the process of book creation, product synchronization, and automated order fulfillment directly from your store's admin panel.

## ✨ Key Features

* **Seamless Book Creation:** Create a book in BookPod directly from the WooCommerce product editing screen.
    * **Auto-Pre-fill:** Clicking "Create Book" automatically sends the product's title, description, and price to the creation form.
    * **Auto-Update:** Once the book is created, the WooCommerce product is automatically updated with the new BookPod ID and status.
* **Smart Synchronization:**
    * **Manual Linking:** Enter an existing Book ID to instantly link a product.
    * **Auto-Fill Data:** Automatically populates empty WooCommerce fields (Title, Description, Price, Tags) with data fetched from BookPod upon linking or creation.
* **Automated Order Fulfillment:** Automatically sends orders to the BookPod API immediately upon purchase completion (configurable per product).
* **Direct Access:** Provides a direct link to edit the book in the BookPod dashboard from the product page.

## 📋 Requirements

* WordPress 5.0 or higher
* WooCommerce installed and active
* BookPod Store User ID & Token

## 🚀 Installation & Setup

1.  **Upload Plugin:**
    * Go to your WordPress Admin Dashboard.
    * Navigate to **Plugins > Add New**.
    * Click the **Upload Plugin** button at the top.
    * Choose the plugin **ZIP file** and click **Install Now**.
2.  **Activate:** Click **Activate Plugin** once the installation is complete.
3.  **Configure:**
    * Go to **Settings > BookPod Author Tools**.
    * Enter your **BookPod Store User ID** and **BookPod Store Token**.
    * Click **Save Changes**.

## 💻 Usage / Workflow

The plugin is designed to work primarily from within the **WooCommerce Product Editor**:

### 1. Creating a New Book (Recommended Workflow)
If you have a WooCommerce product (even a draft) that doesn't exist in BookPod yet:
1.  Go to the product's **Edit** screen.
2.  Locate the **BookPod** meta box.
3.  Click the **"Create book in BookPod"** button.
    * This will open the creation form with the product's **Title**, **Description**, and **Price** already filled in.
4.  Upload your PDF files and submit the form.
5.  **Result:** You will be redirected back to the product, which will now be linked to the new **BookPod ID**.

### 2. Linking an Existing Book
If the book already exists in BookPod:
1.  Enter the **Book ID** in the BookPod meta box.
2.  Click **Enter**.
3.  **Result:** The plugin verifies the ID and automatically fills in any missing product details (Title, Price, etc.) from BookPod.

### 3. Automating Orders
* When a customer buys a BookPod product, the order details will be sent to the BookPod API automatically.

## ⚙️ Developer Notes

* **Environment Configuration:**
    The plugin includes a constant `BPAT_MOCK_SUCCESS` in `bpat-book.php`.
    * Set to `true` for local testing (simulates API responses).
    * **Ensure it is set to `false` in production** to enable real API communication.

---
**Created by:** Rachel