Important
VAT/tax calculation is only suitable for my usecase (enter prices without and only add it at checkout, relying on built-in tax calculation methods). Depending on what regions and tax laws you have to comply with this may or may not apply to you.
Bulk update existing WooCommerce Subscriptions when the prices of products change via WP-CLI (verbose by default).
I do this through WP-CLI because depending on how many subscriptions you might have it didn't seem right to waste resources running this through the WP-Admin UI, and using WP-CLI makes it a breeze to keep a log of each item that's been updated in case something seems to be wrong.
- Install either as an MU-Plugin (single file) or via regular plugin installation means.
- SSH to your server (some providers give you a console for this, otherwise do so manually) and navigate to your WP installation directory.
- You should both take a backup (
wp wcsr backup
) and dry run the recalculate command (wp wcsr recalculate --dry-run
) before you run for real withwp wcsr recalculate
. - You'll see a success message upon successful recalculation! 🎉
wp wcsr backup
Create an SQL dump of subscriptions which may be affected (across wp_posts
, wp_post_meta
, woocommerce_order_items
, and woocommerce_order_itemmeta
). A file named wcsr_backup_<dd-mm-yy_hh-mm-ss>.sql
will be created in your WP content directory (normally /wp-content/
).
wp wcsr restore --file=<file>
Required. Specify the SQL dump of subscriptions that will be restored.
- Type: string
wp wcsr recalculate [--dry-run] [--id=<subscription_id>]
Update the active WC Subscriptions subscriptions which have changed in price, taking into account VAT/tax if in use.
Perform a dry run without writing changes to the database (you may find this useful if you want to test if your store's VAT/tax settings are correctly applied here).
- Type: boolean
- Default: false
Specify a single subscription ID to recalculate. If omitted, process all active subscriptions.
- Type: integer
- Default: null