fix get customer tokens limit (#29850)

Make it easier to support many payment methods (within My Account > Payment Methods page).

* Update includes/class-wc-payment-tokens.php

Better backward-compatible by @jonathansadowski

Co-authored-by: jonathansadowski <jonathansadowski@users.noreply.github.com>

* Add docblock for new filter `woocommerce_get_customer_payment_tokens_limit`.

* Add changelog.

Co-authored-by: Yehuda Hassine <yehuda@myinbox.in>
Co-authored-by: jonathansadowski <jonathansadowski@users.noreply.github.com>
Co-authored-by: barryhughes <3594411+barryhughes@users.noreply.github.com>
This commit is contained in:
Yehuda Hassine 2022-11-17 13:55:12 +02:00 committed by GitHub
parent abcd2a799a
commit 9337b3b5a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 0 deletions

View File

@ -0,0 +1,4 @@
Significance: patch
Type: tweak
Adds new filter `woocommerce_get_customer_payment_tokens_limit` to set limit on number of payment methods fetched within the My Account page.

View File

@ -74,6 +74,14 @@ class WC_Payment_Tokens {
array(
'user_id' => $customer_id,
'gateway_id' => $gateway_id,
/**
* Controls the maximum number of Payment Methods that will be listed via the My Account page.
*
* @since 7.2.0
*
* @param int $limit Defaults to the value of the `posts_per_page` option.
*/
'limit' => apply_filters( 'woocommerce_get_customer_payment_tokens_limit', get_option( 'posts_per_page' ) ),
)
);