Do you want to make changes to your website without disrupting the user experience or risking duplicate payments? Look no further! WooCommerce Subscriptions & Subscriptions by WooCommerce Payments have got you covered. With these plugins, you can easily handle staging sites and migrations, ensuring a smooth testing process.
What is a Staging Site?
Before we delve into the details, let’s clarify what we mean by a staging site. Essentially, a staging site is a clone of your website that allows you to test changes before implementing them on the live site. It’s a safe space where you can experiment without affecting your customers’ experience.
How Subscriptions Work on Staging Sites
To protect you from duplicate payments, Subscriptions and Subscriptions by WooCommerce Payments disable automatic payments and subscription-related emails when your staging site’s URL differs from the URL of the site where they were first activated. This ensures that you won’t accidentally charge your customers twice or inundate them with unnecessary emails.
When your site is in staging mode, Subscriptions will display a warning in the administration area, clearly indicating that the site is in testing mode. It will also show you the URL it considers to be the live site, so you can easily keep track of your configurations.
Staging Site Notice
Moreover, to make it even more apparent that you are working on a staging site, Subscriptions will display a staging badge next to the WooCommerce > Subscriptions menu item. This way, you can easily distinguish between your live and staging sites.
You can still test subscription renewals on your staging site, but Subscriptions will use the manual renewal process and refrain from sending any subscription-related emails. This ensures that your customers won’t receive any unnecessary notifications during the testing phase.
How to Enable Automatic Payments and Subscription-Related Emails on Staging Sites
Although automatic payments and subscription-related emails are disabled by default on staging sites, it is possible to enable them if necessary. However, please note that this action should be taken with caution to avoid any unintended consequences.
If you want to allow automatic payments and subscription-related emails on your staging site, you can follow these steps:
- Make sure you are within the WordPress admin area.
- Click on the Enable Automatic Payments button displayed in the staging site notice.
In case you dismissed the notice or it is missing, and you still want to enable automatic payments on the staging site, you can do the following:
- Go to example.com/wp-admin/?wcs_display_staging_notice=true while logged in as an administrator (replace example.com with your site’s URL).
Please note that if these methods don’t resolve the issue, you may need to directly edit and access the database, which should only be done if you are confident in your technical skills. Don’t forget to back up your site and database before proceeding.
Migrating Your Site’s Database to a New Server
If you are migrating your site’s database to a new server and want to ensure a seamless transition, there are a few additional considerations to keep in mind.
If the domain name remains the same after migration, the staging mode will not be triggered on the new site. This means that renewal payments will be processed as if the site were in live mode. To avoid any confusion or accidental charges, you can take the following steps:
- Change the site URL to switch it into staging mode.
- Disable Action Scheduler’s default queue runner to prevent Subscriptions from triggering renewal events.
By implementing these steps, you can ensure that payments are not processed on the staging site, even temporarily.
Switching a Live Site to Staging
In some cases, you may need to switch your live site to staging mode. To do this, you can edit the
wc_subscriptions_siteurl from within the
_options table to a different value than the current site URL.
If your web host allows it, you can also change the value for
wc_subscriptions_siteurl from the WP Admin by viewing the options page from
/wp-admin/options.php. Follow these steps within the WP Admin:
- Append the site URL to include
https://YOUR-DOMAIN.com/wp-admin/options.php(replace YOUR-DOMAIN.com with your site’s domain URL).
- Search the options page for
- Change the value of that option to something other than the current site URL (suggestion: add a character to the end of that value).
By completing these steps, you can effectively switch your live site to staging mode.
Best Practices and Additional Recommendations
To decommission your old site and avoid any issues with duplicate payments or emails, it is essential to take the following steps:
- Change the site’s URL to switch it into staging mode. In some cases, the
wc_subscriptions_siteurlvalue might also need to be updated.
- Disable Action Scheduler’s default queue runner to ensure that the WooCommerce Subscriptions plugin doesn’t trigger renewal events.
By completing these actions, you can prevent any unintended consequences on your old site.
To ensure that customers do not receive any emails from your duplicate site, we recommend using a plugin like Disable Emails. This will help you prevent any confusion or customer dissatisfaction during the testing phase.
By default, Subscriptions in staging mode will still trigger scheduled renewals and other events, but no payments will be attempted, and no emails will be sent. If you wish to stop these events from being triggered altogether, you can install and activate the free Action Scheduler – Disable Default Runner plugin.
If you would like to enable subscription-related emails on your staging site, you can define the
WCS_FORCE_EMAIL constant. To enable this constant, follow these steps:
Go to your site’s
Above the line that says
/* That's all, stop editing! Happy blogging. */, add the following code snippet and save the file:
define( 'WCS_FORCE_EMAIL', true );
By incorporating these best practices and recommendations, you can streamline your testing process and ensure that your staging site behaves exactly as intended.
With WooCommerce Subscriptions and Subscriptions by WooCommerce Payments, managing and testing your website on staging sites has never been easier. By disabling automatic payments and subscription-related emails, you can rest assured that your users won’t be charged or bothered during the testing phase. Remember to carefully follow the recommended steps when switching between staging and live mode to avoid any issues. Happy testing!