IMPORTANT: This code is made available in the hope that it will be useful, but without any warranty. See the GNU General Public License included with the code for more details. Automattic or WooCommerce support services are also not available to assist with the use of this code.
Using WooCommerce Subscriptions? Need to test automatic payments on a staging site?
By default, when WooCommerce Subscriptions detects a change in a site's URL, it switches to Staging Mode. In Staging Mode, all subscriptions are forced to use manual renewals. This prevents accidental, duplicate renewal payments being processed by staging sites.
On occasion, there is a need to process automatic payments on staging sites, generally for testing.
This plugin can be used to trigger automatic payments for specific subscriptions when Subscriptions is in Staging Mode.
- Download the latest version of the plugin
- Install & activate the plugin
- Define a
WCS_UPSTAGED_SUBSCRIPTION_IDS
constant - Set its value to a JSON encoded array of subscription IDs (
int
's) - it needs to be JSON encoded to avoidPHP Warning: Constants may only evaluate to scalar values errors
Automatic renewal payments will then be triggered for those subscription IDs.
define( 'WCS_UPSTAGED_SUBSCRIPTION_IDS', json_encode( array( 123, 5813, 2134 ) ) );
While the WCS_UPSTAGED_SUBSCRIPTION_IDS
constant can be defined anywhere, your site's wp-config.php
file is often the best place for defining this type of constant.
The plugin will only trigger automatic payments when:
- the site is in Staging Mode, it does nothing when the site is in Live Mode
- a
WCS_UPSTAGED_SUBSCRIPTION_IDS
constant is defined - the
WCS_UPSTAGED_SUBSCRIPTION_IDS
constant is a JSON encoded array
If those conditions are met, when a scheduled renewal event occurs for a subscription in the WCS_UPSTAGED_SUBSCRIPTION_IDS
array, this plugin will trigger the automatic renewal payment process.
If you find an problem or would like to request this plugin be extended, please open a new Issue.