Skip to content

Instantly share code, notes, and snippets.

@bvdr
Last active October 1, 2020 13:44
Show Gist options
  • Select an option

  • Save bvdr/43373e51fad07176ed8585c4d24467ba to your computer and use it in GitHub Desktop.

Select an option

Save bvdr/43373e51fad07176ed8585c4d24467ba to your computer and use it in GitHub Desktop.
Activate WooCommerce Subscriptions recurring events for custom billing email for testing recurring payments
<?php
/**
* Test recurring payments in staging mode.
* [USAGE] WooCommerce subscriptin is handling subscriptions as manual subscriptions if the 'stage' mode is on.
* Luckly we can hook and filter by signup email. We don't want this to be working with all existing subscriptions so
* we are filtering by email.
*
* [INSTALLATION] This can be packed as mu-plugin.
*
* [DISCLAMER] This is critical developer only information and it can trigger real payments in your stage environment.
* Please be careful and use it on your own risk.
*
* @package WooCommerce Subscriptions
* @category WooCommerce
*/
add_filter( 'woocommerce_subscription_is_manual', 'bo_activate_recurring_payments_for_email', 10, 2 );
function bo_activate_recurring_payments_for_email ( $is_manual, $order ) {
$billing_email = $order->get_billing_email();
$email_string_to_look_for = 'email@bogdan.is';
if ( false !== strpos( $billing_email, $email_string_to_look_for ) ) {
$is_manual = false;
}
return $is_manual;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment