Last active
January 26, 2023 07:49
-
-
Save JPry/644766cbf0401d45da613eafa4c7d8e2 to your computer and use it in GitHub Desktop.
Limit WooCommerce Subscriptions to only 3 payment retries
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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?