WP Manifestindependent plugin directory
manifest / ecommerce / woocommerce-id-rollback

WooCommerce ID Rollback

Roll back post and orders ID numbers.

by XboxHacker · github.com/xboxhacker/woocommerce-id-rollback · website

0stars
0forks

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.zip

Readme

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

  1. Download the plugin files
  2. Upload the entire woocommerce-id-rollback folder to /wp-content/plugins/
  3. Activate the plugin through the 'Plugins' menu in WordPress
  4. 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!

  1. Navigate to WooCommerce > ID Rollback
  2. In the right panel under "Database Backup & Restore", click "Create Backup Now"
  3. Wait for the backup to complete (may take several minutes for large databases)
  4. Optionally, click "Download" to save a copy to your PC

Step 2: Analyze Impact

  1. Enter your last known good order number in the "Target ID" field
  2. The plugin will automatically show the next sequential ID
  3. 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

  1. Review the analysis results carefully
  2. Ensure you have a backup
  3. Click "Execute Rollback"
  4. Type ROLLBACK (all caps) when prompted to confirm
  5. Wait for the operation to complete
  6. 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 .sql file to your computer
  • Keep multiple backups in different locations
  • Can be restored manually via phpMyAdmin if needed

Recommendation

Use both approaches:

  1. Create server-side backup for quick restore
  2. 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:

  1. Posts: All posts with ID > X
  2. Post Meta: All metadata for deleted posts
  3. Comments: All comments on deleted posts
  4. Term Relationships: All taxonomy relationships for deleted posts
  5. Auto-Increment: Resets the posts table auto-increment to X + 1

Database Tables Affected

  • wp_posts
  • wp_postmeta
  • wp_comments
  • wp_term_relationships

Backup Process

The backup creates a complete SQL dump including:

  • All table structures (CREATE TABLE statements)
  • All table data (INSERT statements)
  • 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_time in 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_limit in 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

  1. Always Create Backup First: Never skip this step
  2. Download Critical Backups: Store copies on your local PC
  3. Test Small First: If unsure, test with a smaller rollback
  4. Off-Peak Hours: Perform operations during low traffic
  5. Multiple Backups: Keep several backup versions
  6. Document Changes: Note your target ID and reason for rollback
  7. 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:

  1. Create backup
  2. Enter target ID: 1250
  3. Analyze: Confirms 200 shop_order posts will be deleted
  4. Execute rollback
  5. 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:

  1. Check the Analysis preview before executing
  2. Review PHP error logs
  3. Verify WooCommerce compatibility
  4. 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.

Read the full README on GitHub →