WooCommerce ID Rollback
Roll back post and orders ID numbers.
by XboxHacker · github.com/xboxhacker/woocommerce-id-rollback · website
Install
No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:
wp plugin install https://github.com/xboxhacker/woocommerce-id-rollback/archive/refs/heads/main.zipReadme
WooCommerce ID Rollback Plugin
A comprehensive WordPress plugin for safely rolling back WooCommerce order numbers and WordPress post IDs with backup and restore functionality.
⚠️ WARNING
This plugin performs destructive database operations. ALWAYS create a backup before using this plugin. Improper use can result in permanent data loss.
Features
- Safe ID Rollback: Roll back post IDs and order numbers to a specific target ID
- Detailed Analysis: Preview exactly what will be deleted before executing
- Full Database Backup: Create complete SQL backups of your database
- One-Click Restore: Restore from backups directly through the interface
- Download Backups: Download backup files to your local PC for safekeeping
- Real-time Statistics: View current max post IDs and order numbers
- Impact Preview: See breakdown by post type, orders, metadata, and more
- Transaction Safety: Uses database transactions for rollback operations
- User-Friendly Interface: Clean, organized admin panel
Use Case
This plugin is designed for situations where:
- You've received fraudulent order attempts creating unwanted draft orders
- You need to reset order numbers to a known good state
- You want to clean up spam posts/orders without affecting legitimate content
- You know the exact ID of your last legitimate order/post
Installation
- Download the plugin files
- Upload the entire
woocommerce-id-rollbackfolder to/wp-content/plugins/ - Activate the plugin through the 'Plugins' menu in WordPress
- Navigate to WooCommerce > ID Rollback
File Structure
woocommerce-id-rollback/
├── woocommerce-id-rollback.php (main plugin file)
└── assets/
├── admin.css
└── admin.js
Usage
Step 1: Create a Backup
CRITICAL: Always create a backup first!
- Navigate to WooCommerce > ID Rollback
- In the right panel under "Database Backup & Restore", click "Create Backup Now"
- Wait for the backup to complete (may take several minutes for large databases)
- Optionally, click "Download" to save a copy to your PC
Step 2: Analyze Impact
- Enter your last known good order number in the "Target ID" field
- The plugin will automatically show the next sequential ID
- Click "Analyze Impact" to see what will be deleted:
- Total posts by type
- List of specific orders
- Metadata counts
- Comments
- Term relationships
Step 3: Execute Rollback
- Review the analysis results carefully
- Ensure you have a backup
- Click "Execute Rollback"
- Type
ROLLBACK(all caps) when prompted to confirm - Wait for the operation to complete
- The page will automatically reload
Step 4: Verify Results
After rollback:
- Check that your next order has the correct sequential number
- Verify that fraudulent orders are gone
- Test creating a new order to confirm numbering
Backup Storage
Server-Side Storage (Default)
- Location:
wp-content/uploads/wc-id-rollback-backups/ - Protected: Directory is protected with
.htaccess - Fast Restore: Server-side backups can be restored quickly
- Limitation: Lost if server has issues
Local PC Storage (Recommended for Critical Backups)
- Click "Download" button next to any backup
- Save the
.sqlfile to your computer - Keep multiple backups in different locations
- Can be restored manually via phpMyAdmin if needed
Recommendation
Use both approaches:
- Create server-side backup for quick restore
- Download critical backups to your PC for disaster recovery
Database Size Considerations
| Database Size | Backup Time | Storage Method | Notes |
|---|---|---|---|
| < 50 MB | < 1 minute | Server or Local | Both work well |
| 50-200 MB | 1-5 minutes | Server + Local download | Download important backups |
| 200-500 MB | 5-15 minutes | Server + Local download | Ensure adequate PHP memory |
| > 500 MB | 15+ minutes | Consider manual backup | May need command-line tools |
Safety Features
1. Transaction Protection
All rollback operations use MySQL transactions. If anything fails, changes are automatically rolled back.
2. Confirmation Required
Execute operations require typing exact confirmation text to prevent accidental clicks.
3. Analysis Preview
See exactly what will be deleted before committing to the operation.
4. Backup Integration
Easy backup creation and restore built directly into the interface.
5. Permission Checks
Only users with manage_woocommerce capability can access the plugin.
Technical Details
What Gets Deleted
When you roll back to target ID X, the plugin deletes:
- Posts: All posts with
ID > X - Post Meta: All metadata for deleted posts
- Comments: All comments on deleted posts
- Term Relationships: All taxonomy relationships for deleted posts
- Auto-Increment: Resets the posts table auto-increment to
X + 1
Database Tables Affected
wp_postswp_postmetawp_commentswp_term_relationships
Backup Process
The backup creates a complete SQL dump including:
- All table structures (
CREATE TABLEstatements) - All table data (
INSERTstatements) - Proper escaping and NULL handling
- Foreign key management
Requirements
- WordPress 5.8 or higher
- WooCommerce 5.0 or higher
- PHP 7.4 or higher
- MySQL 5.7 or higher
- User capability:
manage_woocommerce
Recommended Server Settings
For optimal performance with backups:
max_execution_time = 300
memory_limit = 512M
post_max_size = 256M
upload_max_filesize = 256M
Troubleshooting
Backup Takes Too Long
- Increase
max_execution_timein php.ini - Consider using command-line backup tools for very large databases
- Try backing up during low-traffic periods
Memory Errors During Backup
- Increase
memory_limitin php.ini - Use manual backup methods (phpMyAdmin, mysqldump)
Restore Fails
- Check file permissions on backup directory
- Verify backup file is not corrupted
- Try restoring manually via phpMyAdmin
- Check PHP error logs for details
Can't Find Backup Directory
- Directory:
wp-content/uploads/wc-id-rollback-backups/ - Check folder permissions (should be 755 or 775)
- Ensure WordPress can write to uploads directory
Best Practices
- Always Create Backup First: Never skip this step
- Download Critical Backups: Store copies on your local PC
- Test Small First: If unsure, test with a smaller rollback
- Off-Peak Hours: Perform operations during low traffic
- Multiple Backups: Keep several backup versions
- Document Changes: Note your target ID and reason for rollback
- Verify After: Check results immediately after rollback
Example Scenario
Situation: You have legitimate orders up to #1250, but fraudulent attempts created draft orders #1251-1450.
Solution:
- Create backup
- Enter target ID:
1250 - Analyze: Confirms 200 shop_order posts will be deleted
- Execute rollback
- Next order will be #1251
Security
- Backup directory protected with
.htaccess - Nonce verification on all AJAX requests
- Capability checks on all operations
- SQL injection prevention via
$wpdb->prepare() - No direct file access allowed
Support
For issues or questions:
- Check the Analysis preview before executing
- Review PHP error logs
- Verify WooCommerce compatibility
- Ensure proper user permissions
License
GPL v2 or later
Changelog
Version 1.0.2
- Prevent hitting Enter on the Target ID field from submitting the form and blanking the screen
- Bump plugin and asset versions so caches pick up the fix
Version 1.0.0
- Initial release
- Complete rollback functionality
- Full backup and restore system
- Detailed analysis and statistics
- Transaction-protected operations
Credits
Developed for WooCommerce store owners who need precise control over order numbering and post IDs.
Remember: This plugin performs irreversible database operations. Always maintain current backups and test thoroughly before use in production environments.