Skip to content

Instantly share code, notes, and snippets.

@JPry
Last active January 26, 2023 07:49
Show Gist options
  • Save JPry/644766cbf0401d45da613eafa4c7d8e2 to your computer and use it in GitHub Desktop.
Save JPry/644766cbf0401d45da613eafa4c7d8e2 to your computer and use it in GitHub Desktop.
Limit WooCommerce Subscriptions to only 3 payment retries
<?php
add_filter( 'wcs_default_retry_rules', 'jpry_limit_3_retries' );
/**
* Limit the WooCommerce Subscriptions retry system to only 3 retries.
*
* This keeps the existing retry rules, but only the first 3. Everything thereafter
* is discarded.
*
* @see WCS_Retry_Rules::$default_retry_rules
*
* @param array $rules The array of retry rules.
* @return array The filtered retry rules.
*/
function jpry_limit_3_retries( $rules ) {
return array_slice( $rules, 0, 3 );
}
@karim1104
Copy link

Hi Jeremy, I believe the current config is to retry 7 times, and your code limits it to 3, but I was wondering if it's possible to just let it keep trying perpetually until it succeeds or until I manually mark it as failed. What do you think? Is that possible?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment