Skip to content

Commit

Permalink
Improve condition(s) for disableMollieOnPaymentMethodChange, make sur…
Browse files Browse the repository at this point in the history
…e not to disable payment methods on checkout (because of is_account_page() false positives)
  • Loading branch information
davdebcom committed May 3, 2018
1 parent 48595a5 commit 6b7620c
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions mollie-payments-for-woocommerce/includes/mollie/wc/plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -524,13 +524,17 @@ public static function disableMollieOnPaymentMethodChange( $available_gateways )
// because slugs/endpoints can be translated (with WPML) and other plugins.
// So disabling on is_account_page and $_GET['change_payment_method'] for now.

if ( is_account_page() || ! empty( $_GET['change_payment_method'] ) ) {
foreach ( $available_gateways as $key => $value ) {
if ( strpos( $key, 'mollie_' ) !== false ) {
unset( $available_gateways[ $key ] );
// Only disable payment methods if WooCommerce Subscriptions is installed
if ( class_exists( 'WC_Subscription' ) ) {
// Do not disable is account page is also checkout, do disable on change payment method page (param)
if ( ( ! is_checkout() && is_account_page() ) || ! empty( $_GET['change_payment_method'] ) ) {
// Final check, disable on is_account_page and on Change payment method
foreach ( $available_gateways as $key => $value ) {
if ( strpos( $key, 'mollie_' ) !== false ) {
unset( $available_gateways[ $key ] );
}
}
}

}

return $available_gateways;
Expand Down

0 comments on commit 6b7620c

Please sign in to comment.