feat: Migrate to Google Merchant API and remove Composer dependencies

- Fix ISE 500 error on plugin activation:
  - Defer wc_get_logger() call in Logger class (lazy initialization)
  - Move plugin init to plugins_loaded hook with priority 20
  - Remove invalid Google_Service_ShoppingContent_Reports instantiation

- Migrate from deprecated Content API to new Merchant API:
  - Rewrite Google API class with direct REST calls
  - Implement JWT authentication using PHP OpenSSL
  - Use WordPress wp_remote_* functions for HTTP requests
  - Support Price Competitiveness reports for competitor pricing

- Remove all Composer dependencies:
  - Delete vendor/ directory (~50 packages)
  - Delete composer.json and composer.lock
  - Remove setup scripts and related documentation

- Plugin is now fully self-contained with no external dependencies

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-21 08:29:25 +01:00
parent 366352fb14
commit d1f3607895
32462 changed files with 344 additions and 4063131 deletions

View File

@@ -4,12 +4,13 @@ A production-ready WooCommerce plugin that automatically adjusts sale prices bas
## Description
This plugin connects to Google Merchant Center API to retrieve competitive pricing data and automatically updates your WooCommerce product prices to stay competitive while maintaining your desired profit margins.
This plugin connects to the Google Merchant API to retrieve competitive pricing data and automatically updates your WooCommerce product prices to stay competitive while maintaining your desired profit margins.
## Features
- **Automated Daily Price Updates**: Schedule automatic price adjustments using WordPress cron
- **Google Merchant Center Integration**: Connects via Google Content API for Shopping
- **Google Merchant API Integration**: Uses the new Google Merchant API (replaces deprecated Content API)
- **No External Dependencies**: Self-contained plugin with no Composer requirements
- **Tax-Aware Pricing**: Handles both tax-inclusive and tax-exclusive pricing configurations
- **Minimum Margin Protection**: Never sell below your cost + minimum margin
- **In-Stock Only Processing**: Only updates products that are currently in stock
@@ -22,35 +23,25 @@ This plugin connects to Google Merchant Center API to retrieve competitive prici
- WordPress 5.8 or higher
- WooCommerce 5.0 or higher
- PHP 7.4 or higher
- PHP OpenSSL extension (for JWT authentication)
- Google Merchant Center account
- Google Service Account with Content API access
- Google Service Account with Merchant API access
## Installation
### Quick Install (Recommended)
1. Download the plugin with vendor libraries included (complete package)
1. Download the plugin
2. Upload to `/wp-content/plugins/informatiq-smart-google-pricing/`
3. Activate the plugin through the 'Plugins' menu in WordPress
4. Configure settings under WooCommerce > Smart Pricing
### Manual Setup (If vendor directory is missing)
1. Upload the plugin files to `/wp-content/plugins/informatiq-smart-google-pricing/`
2. Set up Google API Client library (see `VENDOR-SETUP.md` for details):
- **Option A**: Run `composer install` in the plugin directory
- **Option B**: Manually download and extract Google API Client to `vendor/` directory
3. Activate the plugin through the 'Plugins' menu in WordPress
4. Configure settings under WooCommerce > Smart Pricing
The plugin includes a custom autoloader that works with manually included libraries, so Composer is not required for end users.
No Composer or external dependencies required - the plugin is fully self-contained.
## Configuration
### Google Merchant Center Setup
1. Create a Google Cloud Project
2. Enable the Content API for Shopping
2. Enable the Merchant API
3. Create a Service Account and download the JSON key
4. Grant the service account access to your Merchant Center account
@@ -67,7 +58,7 @@ The plugin includes a custom autoloader that works with manually included librar
1. **Daily Automation**: The plugin runs automatically based on your configured schedule
2. **Product Matching**: Matches WooCommerce products with Google Merchant Center via SKU/GTIN
3. **Competitive Analysis**: Retrieves the lowest competitor price from Google
3. **Competitive Analysis**: Retrieves competitive pricing data from Google's Price Competitiveness reports
4. **Price Calculation**:
- Calculates new price as: Competitor Price - Random Offset (0.05-0.20)
- Ensures price never goes below Cost + Minimum Margin
@@ -123,9 +114,7 @@ The plugin supports multiple update frequencies:
- Twice daily (every 12 hours)
- Every 6 hours
## Development
### File Structure
## File Structure
```
informatiq-smart-google-pricing/
@@ -141,22 +130,19 @@ informatiq-smart-google-pricing/
│ ├── class-informatiq-sp-logger.php
│ ├── class-informatiq-sp-price-updater.php
│ └── class-informatiq-sp-scheduler.php
├── composer.json
├── languages/
├── informatiq-smart-google-pricing.php
├── README.md
└── uninstall.php
```
### Dependencies
## API Notes
The plugin uses Composer for dependency management:
This plugin uses the new Google Merchant API which replaces the deprecated Content API for Shopping. Key differences:
```bash
composer install
```
Main dependencies:
- `google/apiclient`: ^2.15
- **Base URL**: `https://merchantapi.googleapis.com`
- **Pricing**: Amounts are in micros (1,000,000 micros = 1 unit of currency)
- **Resource naming**: Uses hierarchical names like `accounts/{id}/products/{product}`
## Support
@@ -174,6 +160,12 @@ GPL v2 or later
## Changelog
### 2.0.0
- Migrated to Google Merchant API (from deprecated Content API)
- Removed Composer/vendor dependencies
- Self-contained plugin with direct REST API calls
- JWT-based authentication using PHP OpenSSL
### 1.0.0
- Initial release
- Google Merchant Center integration