feat: implement status automation and router pattern
- Implemented modular status automation system (statusHandlers.ts). - Added handlers for 'Published' (Active/Qty 1), 'Sold' (Active/Qty 0), and 'Drafted'. - Refactored onEdit triggers into a central Router pattern in OnEditHandler.ts. - Updated Product.ts to support explicit quantity setting (fixed 0 value bug). - Updated shopifyApi.ts to implement SetInventoryItemQuantity (using ignoreCompareQuantity). - Consolidated triggers into single onEditHandler. - Updated project documentation.
This commit is contained in:
@ -59,13 +59,19 @@ Configuration, including API keys, is stored in a dedicated Google Sheet named "
|
||||
|
||||
Since Apps Script functions must be top-level to be triggered or attached to buttons, `src/global.ts` explicitly exposes necessary functions from the modules to the global scope.
|
||||
|
||||
### 5. Status Automation (`src/statusHandlers.ts`)
|
||||
|
||||
A modular system handles changes to the `status` column. It uses a registry of `StatusHandler` implementations:
|
||||
- **Published**: Sets Shopify Status `ACTIVE`, Quantity `1`.
|
||||
- **Sold/Artist Swap**: Sets Shopify Status `ACTIVE`, Quantity `0`.
|
||||
- **Drafted**: Sets Shopify Status `DRAFT`.
|
||||
|
||||
## Triggers
|
||||
|
||||
Triggers are managed programmatically via `src/triggers.ts`. Running `reinstallTriggers` will wipe existing project triggers and set up the standard set:
|
||||
- `onEdit` -> `newSkuHandler`
|
||||
- `onEdit` -> `matchProductToShopifyOnEditHandler`
|
||||
- `onEdit` -> `onEditQueue`
|
||||
- `onEdit` -> `onEditHandler` (Main Router)
|
||||
- `TimeBased (1 min)` -> `processBatchedEdits`
|
||||
- `TimeBased (10 min)` -> `checkRecentSales`
|
||||
|
||||
### 5. Troubleshooting Panel (`src/sidebar.ts`, `src/Sidebar.html`)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user