File tree Expand file tree Collapse file tree 1 file changed +33
-2
lines changed
woocommerce/payment-gateway Expand file tree Collapse file tree 1 file changed +33
-2
lines changed Original file line number Diff line number Diff line change @@ -236,17 +236,48 @@ public function lib_includes() {
236236 /** My Payment Methods methods ***********************************/
237237
238238
239+ /**
240+ * Instantiates the My Payment Methods table class instance when a user is
241+ * logged in on an account page and tokenization is enabled for at least
242+ * one of the active gateways
243+ *
244+ * @since 4.0.0
245+ */
239246 public function maybe_init_my_payment_methods () {
240247
241- if ( is_account_page () && is_user_logged_in () ) {
248+ if ( is_account_page () && is_user_logged_in () && $ this -> tokenization_enabled () ) {
242249
243250 $ this ->my_payment_methods = $ this ->get_my_payment_methods_instance ();
244251 }
245252 }
246253
254+
255+ /**
256+ * Returns true if tokenization is supported and enabled for at least one
257+ * active gateway
258+ *
259+ * @since 4.2.0-beta
260+ * @return bool
261+ */
262+ public function tokenization_enabled () {
263+
264+ foreach ( $ this ->get_gateways () as $ gateway ) {
265+
266+ if ( $ gateway ->is_enabled () && $ gateway ->supports_tokenization () && $ gateway ->tokenization_enabled () ) {
267+ return true ;
268+ }
269+ }
270+
271+ return false ;
272+ }
273+
274+
247275 /**
276+ * Returns the My Payment Methods table instance, overrideable by concrete
277+ * gateway plugins to return a custom instance as needed
248278 *
249- * @return SV_WC_Payment_Gateway_My_Payment_Methods
279+ * @since 4.0.0
280+ * @return \SV_WC_Payment_Gateway_My_Payment_Methods
250281 */
251282 protected function get_my_payment_methods_instance () {
252283
You can’t perform that action at this time.
0 commit comments