| 开发者 | dineshinau |
|---|---|
| 更新时间 | 2026年11月12日 07:09 |
| PHP版本: | 7.4 及以上 |
| WordPress版本: | 7.1 |
| 版权: | GPLv3 |
| 版权网址: | 版权信息 |
new_cogs column, then import the file to preview your changes.
Use this format for your CSV file, replacing the example IDs, SKUs, and costs with your product data:
id,sku,new_cogs
123,PRODUCT-001,25.50
124,PRODUCT-002,40.00
Your file must include new_cogs and at least one product identifier: id or sku.
id or sku. If both are provided, they must identify the same product.25.50.cogs when the new_cogs header is missing.
XLSX imports read raw values from the first worksheet. Replace formulas with values and store SKUs as text to preserve leading zeros.
XLSX requires PHP's ZIP, XMLReader and DOM extensions. Exports use CSV format.
Preview and apply
Preview preparation runs in background batches without changing products. Progress is saved between batches, and you can close the page and return to check it. Preparation time varies with file size, product mix, hosting, and background worker availability.
When ready, review products, download validation errors if needed, select products, review the selected changes, and confirm the update. Preparation can be cancelled separately from an applied update. Completed imports with no skipped, failed, or unprocessed products have no update error report to download.
Original uploads are deleted after preparation. Staged previews and reports expire after about 24 hours. Retention extends while an applied update is active.
History and retention
Operation history and original cost records follow the retention period set in Settings. See the retention FAQ below. Daily cleanup preserves active operations and data needed for reports.
The plugin also keeps records that prevent the same preview from being applied more than once, including simultaneous Apply requests. These records follow the configured retention period and are removed only when they are no longer needed.
Run background updates with WP-CLI
Use Action Scheduler's CLI runner for import preview preparation and confirmed updates while the editor continues to show progress and accept cancellations. See the Action Scheduler documentation for more information.
Import preview workers must run on the upload server under the same operating-system account as PHP. This lets them read the private temporary uploads.
If your shell uses a different account, ask your host to run the command under PHP's account. Ordinary product updates do not need the uploaded file.
During preparation, worker logs show the stage, checked row count, and batch size. Total and remaining row counts become available after reading finishes.
After uploading an import for preview or confirming an update in the editor, run this command from your WordPress directory:
wp action-scheduler run --group=bulk-cogs-editor --batch-size=1 --batches=0
Check the queue with:
wp action-scheduler status --group=bulk-cogs-editor
The status report covers the site's full Action Scheduler queue.
The run command processes due plugin actions for all users and exits when none remain. It does not wait for scheduled retries. --batch-size counts scheduled actions, not products.
If another worker owns the available batch, wait for it to finish or run:
wp action-scheduler run --group=bulk-cogs-editor --batch-size=1 --batches=0 --force
The plugin prevents two workers from changing the same operation simultaneously. Using --force can still increase server load.
Keep the normal background runner enabled for retries. If your host runs the command on a schedule, use a process lock to prevent overlapping command runs.
For performance checks, prefix the command with time. WooCommerce > Status > Logs under source dkbce records worker timing and runner details.
Requirements
/wp-content/plugins/bulk-cogs-editor-for-woocommerce directory, or install the plugin through the WordPress Plugins screen.Yes. Settings > Default rollback mode offers Keep rollback history (the initial default) and No rollback history. In the update confirmation popup, the Keep rollback history checkbox starts with that default and can be changed for the individual bulk update or CSV import. Its explanation updates as you change it. With history enabled, original costs and detailed product changes remain available for the configured retention period. With history disabled, the operation cannot be rolled back and detailed cost-change history is not retained. Operation results and retry protection remain available. Temporary retry journals are removed by background cleanup after completion, failure, or cancellation. Changing the default does not change existing operations.
Update progress refreshes every 10 seconds for fewer than 1,000 selected items, or every 25 seconds for 1,000 or more. While the total is unknown, polling uses 25 seconds. Use Refresh status for an immediate update. Bulk-update progress is checkpointed after 50 products or 10 seconds, and at chunk boundaries or worker exit. Workers continue checking for cancellation every second between products.
Errors and operation completion summaries remain logged. Detailed worker timings and routine per-product diagnostics are disabled by default. To enable them temporarily for troubleshooting or benchmarking, add define( 'DKBCE_DIAGNOSTICS', true ); to wp-config.php. This does not change Query Monitor or other site-wide profiling settings.
Use Bulk edit for one cost action across a selected group. Use CSV import when individual products need different values. The steps for both workflows appear above.
Yes. Both formats support product IDs or SKUs. See the import section above for required columns, file requirements, and validation steps.
Yes. Keep the exported product IDs or SKUs unchanged when preparing your updates. Export produces CSV even if a previous import used XLSX; see the sample CSV above.
Yes. It requires WooCommerce 10.3 or later with native COGS enabled. If the feature is disabled or unavailable, the editor explains what is required.
Yes. The percentage action applies to your selected products. Products without a saved cost are skipped; use Set exact cost to assign their initial values.
No. Finding products or validating an import only prepares a preview. Product costs change after you explicitly confirm the update.
No. The editor includes task-specific Help and instructions, field guidance, and cost examples. Use the documentation or video when you need more detail.
Expand Recent activity for the latest completed operation, including updated counts, completion time, elapsed time, and highlighted problems. Open History to inspect earlier operations.
When a bulk update finishes in the open editor, its product selection is reused with current costs for another preview, even if those costs no longer match the original filters. Edit filters to narrow that selection. Choose Reset filters to start a new selection.
Yes. You can move between Bulk edit, CSV import / export, History, and Settings while a background operation runs. Controls that could conflict with it stay disabled until the operation finishes.
Choose Stop remaining updates, or Cancel rollback for a rollback, and confirm in the editor dialog. Cancel or Escape closes the dialog without requesting cancellation. Saved cost changes remain, and the active worker may take a short time to stop. Import preview preparation has its own Cancel preparation control with a confirmation dialog. Cancelling preparation does not change product costs; upload the file again to prepare another preview.
Try normal cancellation first. If it does not work, a WooCommerce manager can open Settings, choose Force clear current operation, review the warning, and confirm. This resets the current user's editor operation and import preview references and requests cancellation. It does not restore costs or immediately stop an active worker. Saved changes, operation history, and retained rollback data are kept. Check History before starting another update.
Open History, select View details, and choose Review rollback when original costs are retained. Compare current and original values, then choose Confirm rollback. Expired operations and older records that contain only summary results cannot be rolled back. Restoring changes saved before cancellation also requires a separate rollback.
Choose the skip-changed policy in Settings to preserve later cost edits. Choose overwrite to restore recorded original costs instead. The policy shown during review remains fixed for that rollback attempt. If a rollback is cancelled or does not finish, review a new attempt for the remaining products. Already restored products are excluded, even if edited again later.
Choose 30 days, 90 days, or a custom period of 1 to 36,500 days in Settings. The default is 30 days. Shortening retention also affects existing history. Extending it cannot recover original costs already deleted by scheduled cleanup.
Variations are treated as individual product records. You can filter and update COGS on variations directly, and variable parent products will not be changed when only variations are selected and updated.
Each category, product type, stock status, and available brand dropdown has a "Select all" checkbox. Check it to select every option, or uncheck it to clear the selection. You can still select individual options. An empty filter does not restrict the results.
Selecting all categories requires products to have a category assignment. Variations match the categories assigned to their parent product. Products without categories, and variations whose parent has no categories, are excluded. Use the "All categories" link in the dropdown or clear the category selection to remove this restriction.
Yes. The dropdown lists both parent and child categories in a flat list. Selecting a parent category also matches products in its child categories and variations of those products.
Yes. The result message shows the total followed by separate product and variation counts, for example: "950 matches: 300 products and 650 variations." The product count excludes variation records. The counts cover all matching results, not just the current preview page.
Percentage and fixed-amount adjustments skip products without a saved COGS value. Use Set exact cost to assign one. WooCommerce treats zero as empty; use Clear cost to remove a saved value.
Updates run in background batches, so you can close the browser and return to the editor for progress. Completion depends on hosting and background worker availability. Cancelling keeps changes already saved; it does not undo them.
No. The plugin only modifies the WooCommerce Cost of Goods Sold value.
If you have a suggestion to improve the plugin, please open an issue on GitHub or use the support forum on WordPress.org.
new_cogs column for preparing cost updates.cogs header when new_cogs is absent.DKBCE_DB_VERSION, version comparison, and WordPress dbDelta() when the stored schema version is older.DKBCE_ prefix autoloader.