Allow create payment when changing subscription payment method (WIP)

This commit is contained in:
Emili Castells Guasch 2024-01-08 12:40:56 +01:00
parent 16eebecc5a
commit dc9ad87b3e
3 changed files with 59 additions and 43 deletions

View file

@ -212,6 +212,19 @@ trait ContextTrait {
return $page_id && is_page( $page_id ) && isset( $wp->query_vars['add-payment-method'] );
}
/**
* Checks whether this user is changing the payment method for a subscription.
*
* @return bool
*/
private function is_subscription_change_payment_method_page(): bool {
if ( isset( $_GET['change_payment_method'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
return wcs_is_subscription( wc_clean( wp_unslash( $_GET['change_payment_method'] ) ) ); // phpcs:ignore WordPress.Security.NonceVerification
}
return false;
}
/**
* Checks if it is the block editor page.
*/