admin管理员组文章数量:1123161
I am looking to change the payment retry rules.
I’m following the guide on /
I’ve found the file wp-content/plugins/woocommerce-subscriptions/includes/payment-retry/class-wcs-retry-rules.php which seems to be where they are specified.
How do I override the rules so they’re not reset every time I update the plugin? I am looking to retry after 24 hours and 7 days e.g.
$this->default_retry_rules = apply_filters( 'wcs_default_retry_rules', array(
array(
'retry_after_interval' => DAY_IN_SECONDS, // how long to wait before retrying
'email_template_customer' => '', // don’t bother the customer yet
'email_template_admin' => 'WCS_Email_Payment_Retry',
'status_to_apply_to_order' => 'pending',
'status_to_apply_to_subscription' => 'on-hold',
),
array(
'retry_after_interval' => DAY_IN_SECONDS * 7,
'email_template_customer' => 'WCS_Email_Customer_Payment_Retry',
'email_template_admin' => 'WCS_Email_Payment_Retry',
'status_to_apply_to_order' => 'pending',
'status_to_apply_to_subscription' => 'on-hold',
),
) );
}
I am looking to change the payment retry rules.
I’m following the guide on https://woocommerce.com/document/subscriptions/develop/failed-payment-retry/
I’ve found the file wp-content/plugins/woocommerce-subscriptions/includes/payment-retry/class-wcs-retry-rules.php which seems to be where they are specified.
How do I override the rules so they’re not reset every time I update the plugin? I am looking to retry after 24 hours and 7 days e.g.
$this->default_retry_rules = apply_filters( 'wcs_default_retry_rules', array(
array(
'retry_after_interval' => DAY_IN_SECONDS, // how long to wait before retrying
'email_template_customer' => '', // don’t bother the customer yet
'email_template_admin' => 'WCS_Email_Payment_Retry',
'status_to_apply_to_order' => 'pending',
'status_to_apply_to_subscription' => 'on-hold',
),
array(
'retry_after_interval' => DAY_IN_SECONDS * 7,
'email_template_customer' => 'WCS_Email_Customer_Payment_Retry',
'email_template_admin' => 'WCS_Email_Payment_Retry',
'status_to_apply_to_order' => 'pending',
'status_to_apply_to_subscription' => 'on-hold',
),
) );
}
Share
Improve this question
edited 5 hours ago
LoicTheAztec
253k24 gold badges393 silver badges441 bronze badges
asked 6 hours ago
user7692855user7692855
1,4186 gold badges21 silver badges44 bronze badges
1 Answer
Reset to default 2You should never overwrite any plugin core files, for many different reasons.
In your case, wcs_default_retry_rules
is the right filter hook to change WooCommerce Subscriptions Payment Retry rules.
So the correct code to be used instead is:
add_filter( 'wcs_default_retry_rules', 'custom_wcs_default_retry_rules' );
function custom_wcs_default_retry_rules( $retry_rules ) {
return array(
array(
'retry_after_interval' => DAY_IN_SECONDS, // how long to wait before retrying
'email_template_customer' => '', // don’t bother the customer yet
'email_template_admin' => 'WCS_Email_Payment_Retry',
'status_to_apply_to_order' => 'pending',
'status_to_apply_to_subscription' => 'on-hold',
),
array(
'retry_after_interval' => DAY_IN_SECONDS * 7,
'email_template_customer' => 'WCS_Email_Customer_Payment_Retry',
'email_template_admin' => 'WCS_Email_Payment_Retry',
'status_to_apply_to_order' => 'pending',
'status_to_apply_to_subscription' => 'on-hold',
),
);
}
Code goes in functions.php file of your child theme (or in a plugin). It should work.
Don't forget to replace the original plugin file for class-wcs-retry-rules.php file.
本文标签: phpHow to Change Payment Retry Rules for Woocommerce SubscriptionsStack Overflow
版权声明:本文标题:php - How to Change Payment Retry Rules for Woocommerce Subscriptions? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736551668a1944519.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论