Add context for add payment method

This commit is contained in:
Emili Castells Guasch 2023-12-05 09:34:34 +01:00
parent cb7612851f
commit 29669b501a
3 changed files with 35 additions and 16 deletions

View file

@ -644,7 +644,7 @@ document.querySelector("#payment").before(document.querySelector("#ppcp-messages
return $this->settings->has( 'dcc_enabled' ) && $this->settings->get( 'dcc_enabled' )
&& $this->settings->has( 'client_id' ) && $this->settings->get( 'client_id' )
&& $this->dcc_applies->for_country_currency()
&& in_array( $this->context(), array( 'checkout', 'pay-now' ), true );
&& in_array( $this->context(), array( 'checkout', 'pay-now', 'add-payment-method' ), true );
}
/**

View file

@ -94,6 +94,10 @@ trait ContextTrait {
return 'checkout';
}
if ( $this->is_add_payment_method_page() ) {
return 'add-payment-method';
}
return 'mini-cart';
}
@ -147,4 +151,16 @@ trait ContextTrait {
return true;
}
/**
* Checks whether current page is Add payment method.
*
* @return bool
*/
private function is_add_payment_method_page(): bool {
global $wp;
$page_id = wc_get_page_id( 'myaccount' );
return $page_id && is_page( $page_id ) && isset( $wp->query_vars['add-payment-method'] );
}
}