7.9 KiB
Installation & Setup Guide
Prerequisites
Before installing this plugin, ensure you have:
- WordPress 5.8 or higher
- WooCommerce 5.0 or higher installed and activated
- PHP 7.4 or higher with Composer installed
- Google Merchant Center account with products listed
- Google Cloud Project with Content API for Shopping enabled
Step 1: Install Plugin Files
Option A: Complete Package (Recommended)
If you received the plugin with the vendor/ directory already included:
- Upload the entire plugin directory to
/wp-content/plugins/ - Skip to Step 2 - the plugin is ready to activate!
Option B: Install Dependencies Manually
If the vendor/ directory is empty or missing:
-
Upload the plugin files to your WordPress plugins directory:
cd /wp-content/plugins/ # Upload or clone the plugin files -
Navigate to the plugin directory:
cd informatiq-smart-google-pricing -
Install dependencies using ONE of these methods:
Method 1: Using Composer (easiest)
composer install --no-dev --optimize-autoloaderMethod 2: Manual Download
- Download Google API PHP Client from: https://github.com/googleapis/google-api-php-client/releases
- Extract to
vendor/google/apiclient/ - Download dependencies or see
VENDOR-SETUP.mdfor detailed instructions
Note: The plugin includes a custom autoloader that works with manually placed vendor files, so Composer is optional for end users.
Step 2: Create Google Service Account
-
Go to Google Cloud Console:
- Visit https://console.cloud.google.com/
- Create a new project or select an existing one
-
Enable Content API for Shopping:
- Navigate to "APIs & Services" > "Library"
- Search for "Content API for Shopping"
- Click "Enable"
-
Create Service Account:
- Go to "APIs & Services" > "Credentials"
- Click "Create Credentials" > "Service Account"
- Fill in the service account details:
- Name:
informatiq-pricing-service - Description:
Service account for Smart Pricing plugin
- Name:
- Click "Create and Continue"
- Skip optional steps and click "Done"
-
Create JSON Key:
- Click on the newly created service account
- Go to the "Keys" tab
- Click "Add Key" > "Create New Key"
- Select "JSON" format
- Click "Create"
- Save the downloaded JSON file securely
-
Grant Access to Merchant Center:
- Go to Google Merchant Center (https://merchants.google.com/)
- Navigate to Settings > Users
- Click "Add user"
- Enter the service account email (looks like:
account-name@project-id.iam.gserviceaccount.com) - Assign "Admin" or "Standard" access
- Click "Save"
Step 3: Activate Plugin
- Log in to your WordPress admin panel
- Navigate to Plugins > Installed Plugins
- Find "informatiq-smart-google-pricing"
- Click Activate
Step 4: Configure Plugin Settings
-
Navigate to WooCommerce > Smart Pricing
-
Configure Google Merchant Center Settings:
- Google Merchant ID: Enter your Merchant Center ID (found in Merchant Center settings)
- Service Account JSON: Open the downloaded JSON file and paste its entire contents here
-
Configure Pricing Settings:
- Minimum Margin (%): Set your minimum acceptable profit margin (e.g., 10 for 10%)
- This ensures prices never drop below cost + margin
-
Configure Automation Settings:
- Enable Automatic Updates: Check to enable daily automated updates
- Update Frequency: Choose how often to update prices:
- Once Daily (recommended for most stores)
- Twice Daily (for highly competitive markets)
- Every 6 Hours (for very dynamic pricing)
-
Click Save Settings
Step 5: Test Configuration
- Click the "Test Google API Connection" button
- Wait for the response
- If successful, you'll see: "Connection successful!"
- If failed, check your credentials and API access
Step 6: Run Initial Sync
-
Click the "Run Manual Sync Now" button
-
The plugin will:
- Fetch all in-stock products
- Match them with Google Merchant Center
- Retrieve competitive pricing
- Update sale prices according to your rules
-
Review the results in the "Today's Price Updates" section
Product Requirements
For products to be updated automatically, they must meet these criteria:
- Stock Status: Must be "In Stock"
- SKU: Must have a SKU that matches the product in Google Merchant Center
- GTIN (optional): Can be set via
_gtinmeta field for better matching - Cost (optional): Set product cost using WooCommerce Cost of Goods plugin for accurate margin calculations
Setting Product Cost
To use the minimum margin feature effectively:
-
With Cost of Goods Plugin:
- Install "WooCommerce Cost of Goods" plugin
- Edit each product
- Enter cost in the "Cost of Goods" field
-
Without Cost of Goods Plugin:
- The plugin will use the regular price as a fallback
- This means minimum margin will be calculated from regular price
Monitoring & Maintenance
View Logs
- Navigate to WooCommerce > Smart Pricing
- Scroll to "Today's Price Updates" section
- View detailed logs of all price changes
Check Schedule
- The "Schedule Information" section shows:
- Next scheduled run time
- Last run time and results
- Number of products processed/updated
Troubleshooting
If prices aren't updating:
-
Check WooCommerce Logs:
- Navigate to WooCommerce > Status > Logs
- Select the
informatiq-smart-pricing-...log file - Review error messages
-
Verify Settings:
- Ensure Google API credentials are correct
- Test API connection
- Check that automatic updates are enabled
-
Check Cron:
- Ensure WordPress cron is running properly
- Install "WP Crontrol" plugin to debug cron jobs
- Look for
informatiq_sp_daily_price_updateevent
-
Product Issues:
- Verify products have SKUs
- Ensure products are in stock
- Check that products exist in Google Merchant Center
Advanced Configuration
Custom Cron Schedule
To change the cron schedule programmatically:
// In your theme's functions.php or custom plugin
Informatiq_SP_Scheduler::reschedule( 'daily' ); // or 'twice_daily', 'every_6_hours'
Hooks and Filters
The plugin provides hooks for customization:
// Modify minimum offset
add_filter( 'informatiq_sp_min_offset', function() {
return 0.10; // Minimum $0.10 difference
});
// Modify maximum offset
add_filter( 'informatiq_sp_max_offset', function() {
return 0.50; // Maximum $0.50 difference
});
Security Recommendations
-
Protect Service Account JSON:
- Never commit the JSON key to version control
- Store securely in WordPress database (plugin does this automatically)
- Use environment variables for extra security if needed
-
Limit Service Account Permissions:
- Only grant necessary permissions in Merchant Center
- Use "Standard" access if "Admin" isn't required
-
Regular Audits:
- Review price change logs regularly
- Monitor for unexpected pricing patterns
- Set up alerts for significant price drops
Uninstallation
If you need to remove the plugin:
- Deactivate the plugin from WordPress admin
- Delete the plugin (this will remove all settings and logs)
- The plugin automatically:
- Removes all settings from database
- Deletes the custom log table
- Clears scheduled cron events
Note: Product prices will remain at their last updated values. You'll need to manually adjust them if desired.
Support
For issues or questions:
- Email: contact@malin.ro
- Website: https://informatiq.services
- Documentation: See README.md
Updates
To update the plugin:
- Download the latest version
- Deactivate the old version
- Replace plugin files
- Run
composer installif dependencies changed - Reactivate the plugin
Your settings and logs will be preserved during updates.