WooCommerce Subscriptions can handle staging sites and site migrations. Many hosts provide an easy way to create a clone of your website for testing changes. This is called a staging site.
To prevent processing duplicate payments on a clone of your site, WooCommerce Subscriptions disables automatic payments and subscription-related emails when it detects that the current site’s URL differs from the URL of the site where you first activated the extension.
What is Considered a Staging Site?
↑ Back to topWooCommerce Subscriptions will keep a record of the URL of the site where it is first activated. It considers this to be the live site and will run in live mode. If the site’s URL then changes, it considers the new site to be a staging site and it will run in staging mode.
This means if you first activate Subscriptions on a staging site, Subscriptions will run in live mode on the staging site because it considers this site to actually be your live site.
Because of this, if you want to test Subscriptions on a staging site before running it on your live site, we recommend first activating it on the live site and then creating the staging site from that site’s database.
Developer Note: WooCommerce Subscriptions stores an obscured clone of the WordPress siteurl
value in an option with the name wc_subscriptions_siteurl
. It compares this value with the siteurl
value to see if it has changed.
Duplicate Site Warning
↑ Back to topYou will know when the site is in staging mode because Subscriptions will display a warning in the administration area of your site. This notice also shows which URL Subscriptions considers to be the live site.
Subscriptions will also display a staging badge next to the WooCommerce > Subscriptions menu item when a store is in Staging Mode.
Check if Staging Mode is Enabled
If you are unsure whether you or another administrator on the site has dismissed the notice and want to check if the store is running in Staging mode, you can:
- Go To WooCommerce
- Check the Subscriptions menu item. A red bubble displaying the word Staging indicates the site is in Staging Mode. The absence of any indicator except “Subscriptions” indicates the site is in Live Mode.
Whether the store is running in Staging or Live mode also shows on the Status page. Here is how to find it:
- Go To WooCommerce > Status
- Scroll down to Subscriptions Mode
- Check the value. A red X displaying the word Staging indicates the site is in Staging Mode. A tick mark displaying the word Live indicates the site is in Live Mode.
You will find a row labeled Subscriptions Live URL below this section. This shows the URL that Subscriptions considers to be the live site.
Manual Renewals in Staging Mode
↑ Back to topIn order to prevent collecting duplicate payments from your customers on a staging site, all subscriptions on the staging site will use the manual renewal process. Your live site will continue to take payments as normal. When this occurs, all the subscriptions listed in the WooCommerce > Subscriptions admin table will be Manual Renewal. To view the “live” payment method, you can hover over the ?
to display the note.
If you edit a subscription while the site is in staging mode, the system sets the payment method in the Billing details to Manual Renewal. You can edit the payment method, and these changes will take effect if/when you switch the site to live mode.
If you want to take automatic payments on your staging site site, it is possible to enable automatic payments.
Enabling Automatic Payments on a Staging Site
↑ Back to topTo switch your site from Staging Mode to Live Mode:
- Make sure you’re within the WordPress admin area, e.g.
example.com/wp-admin/
- Select the Enable Automatic Payments button displayed in the staging site notice.
If at first you chose the Quit Nagging Me option, or perhaps this notice is missing, and you 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, replacingexample.com
with your site’s URL.
If this doesn’t help, you still have options, but this involves editing and accessing the database directly. We’d recommend backing up your site and database before using this method.
- Access your database via PhpMyAdmin if your host provides it (or install a plugin like WP phpMyAdmin).
- Search the
wp_options
table for an option with theoption_name
of'wcs_ignore_duplicate_siteurl_notice'
. - Change the option value of the
'wcs_ignore_duplicate_siteurl_notice'
option to “false.” - Save the changes to the option value.
The staging site notice should reappear and you can choose to Enable automatic payments from there.
Email Behavior in Staging Mode
↑ Back to topSubscriptions in staging mode will not send any subscription-related emails. Any emails sent or managed by WordPress, WooCommerce, or another plugin may still be sent from your staging site. To block all emails from your site, install a plugin like Disable Emails.
If you want to send subscription-related emails on your staging site, it is possible to enable the feature to send subscription-relation emails.
Enabling Subscriptions Emails on a Staging Site
↑ Back to topIf you would like to enable subscription-related emails on a staging site, you can define the WCS_FORCE_EMAIL
constant. In order to enable this constant:
- Go to your site’s
wp-config.php
file - Above the line that says
/* That's all, stop editing! Happy blogging. */
, add the following code snippet and save the file:
Enable Staging Mode for WooCommerce Subscriptions
↑ Back to topIt is possible to switch a live site to staging by editing the wc_subscriptions_siteurl
from within the _options
table to anything different from the siteurl
.
If your web host allows it, the value for wc_subscriptions_siteurl
can be changed from the WP Admin by viewing the options page from /wp-admin/options.php. To achieve this from within the WP Admin:
- After logging into your admin area, visit: https://YOUR-DOMAIN.com/wp-admin/options.php (replace YOUR-DOMAIN.com with your site’s domain URL)
- Search the options page for
wc_subscriptions_siteurl
- Change the value of that option to anything other than the current site URL ( Suggestion: add a character to the end of that value. )
Database Migration
↑ Back to topWhen migrating your site’s database from one server to another server, there are additional considerations.
If you have migrated your site’s database and kept the same domain name, the new site will not trigger staging mode. This means Subscriptions will process renewal payments in live mode. To prevent payment processing, even temporarily, you need to:
- Change the WordPress site URL, this will switch that site into staging mode; or
- Disable Action Scheduler’s default queue runner to ensure Subscriptions doesn’t trigger renewal events.
Decommission Your Old Site
↑ Back to topTo decommission the old site and avoid any issues with duplicate payments or emails, you must do at least one of the following:
- Change the site’s URL, this will switch that site into staging mode. In some cases,
wc_subscriptions_siteurl
the value might need to be updated as well. You can follow the steps for enabling staging mode for Woo Subscriptions above. - Disable Action Scheduler’s default queue runner to ensure the Woo Subscriptions plugin doesn’t trigger renewal events.
Without completing one of these steps, your old site will continue to process real recurring payments. We also suggest you block all emails from your duplicate site to prevent customers from receiving any emails from this old site. To do this, you can use a plugin like Disable Emails (this plugin is not made by Woo or endorsed by WooCommerce.com).
Disabling All Scheduled Events
↑ Back to topWhen Subscriptions is in staging mode, it still triggers scheduled renewals and other scheduled events, like expiration, by default. It won’t attempt any payments or send emails for these events, but it will initiate the event as it would on the live site.
To stop the system from triggering these events, install and activate the free Action Scheduler – Disable Default Runner plugin
This plugin disables all events in the scheduling library Woo Subscriptions uses. This library also powers other extensions, like WooCommerce Memberships, so it will also disable any scheduled events for those plugins.
Why Renewal Payments May Not Process on Live Sites
↑ Back to topWhen Subscriptions processes a renewal in Staging mode, it adds the following note to the order notes:
Payment processing skipped – renewal order created on staging site under staging site lock. Live site is at https://example.com/
On occasion, these notes may appear on renewal orders created on the live site. This means the live site is accessible via more than one URL. For example, the site may be accessible via both:
- https://www.example.com
- https://example.com
To process renewals correctly, Subscriptions requires your WordPress site to have only one URL.
To ensure your site is accessible via only one the URL, you can use the WordPress Site URL constants in your wp-config.php
file to set the URL for the site. For example:
define( 'WP_SITEURL', 'https://example.com' ); define( 'WP_HOME', 'https://example.com' );
You should also make sure your web server software, like Apache, is configured to redirect any requests to other URLs to the canonical URL. WordPress has a guide on setting up .htaccess
file correctly. If you need additional help, please contact your web host.
Serving your site under a single URL is good practice as it has other benefits, most notably for SEO. As Moz explains:
Duplicate content is content that appears on the Internet in more than one place. That “one place” is defined as a location with a unique website address (URL)
While not technically a penalty, duplicate content can still sometimes impact search engine rankings. When there are multiple pieces of, as Google calls it, “appreciably similar” content in more than one location on the Internet, it can be difficult for search engines to decide which version is more relevant to a given search query.
Questions and Support
↑ Back to topSomething missing from this documentation? Do you still have questions and need assistance?
- Have a question about a specific extension or theme you’d like to purchase? Click here.
- Already purchased and need some assistance? Get in touch with a Happiness Engineer via the WooCommerce.com Support page and choose this extension name from the “I need help with” dropdown.