mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
Add filter for credit card gateway enabled
This commit is contained in:
parent
daf5af2870
commit
2d3706291b
2 changed files with 39 additions and 7 deletions
|
@ -279,9 +279,9 @@ class CreditCardGateway extends \WC_Payment_Gateway_CC {
|
|||
'woocommerce-paypal-payments'
|
||||
);
|
||||
|
||||
$this->title = apply_filters( 'woocommerce_paypal_payments_credit_card_gateway_title', $this->dcc_configuration->gateway_title(), $this );
|
||||
$this->description = apply_filters( 'woocommerce_paypal_payments_credit_card_gateway_description', $this->dcc_configuration->gateway_description(), $this );
|
||||
$this->card_icons = $card_icons;
|
||||
$this->title = apply_filters( 'woocommerce_paypal_payments_credit_card_gateway_title', $this->dcc_configuration->gateway_title(), $this );
|
||||
$this->description = apply_filters( 'woocommerce_paypal_payments_credit_card_gateway_description', $this->dcc_configuration->gateway_description(), $this );
|
||||
$this->card_icons = $card_icons;
|
||||
|
||||
$this->init_form_fields();
|
||||
$this->init_settings();
|
||||
|
@ -299,10 +299,13 @@ class CreditCardGateway extends \WC_Payment_Gateway_CC {
|
|||
* Initialize the form fields.
|
||||
*/
|
||||
public function init_form_fields() {
|
||||
$this->form_fields = array(
|
||||
'ppcp' => array(
|
||||
'type' => 'ppcp',
|
||||
),
|
||||
$this->form_fields = apply_filters(
|
||||
'woocommerce_paypal_payments_credit_card_gateway_form_fields',
|
||||
array(
|
||||
'ppcp' => array(
|
||||
'type' => 'ppcp',
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -583,6 +586,10 @@ class CreditCardGateway extends \WC_Payment_Gateway_CC {
|
|||
public function init_settings() {
|
||||
parent::init_settings();
|
||||
|
||||
if ( ! apply_filters( 'woocommerce_paypal_payments_credit_card_gateway_should_update_enabled', true ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// looks like in some cases WC uses this field instead of get_option.
|
||||
$this->enabled = $this->is_enabled() ? 'yes' : '';
|
||||
}
|
||||
|
@ -595,6 +602,10 @@ class CreditCardGateway extends \WC_Payment_Gateway_CC {
|
|||
* @return mixed
|
||||
*/
|
||||
public function get_option( $key, $empty_value = null ) {
|
||||
if ( ! apply_filters( 'woocommerce_paypal_payments_credit_card_gateway_should_update_enabled', true ) ) {
|
||||
return parent::get_option( $key, $empty_value );
|
||||
}
|
||||
|
||||
if ( 'enabled' === $key ) {
|
||||
return $this->is_enabled();
|
||||
}
|
||||
|
@ -612,6 +623,10 @@ class CreditCardGateway extends \WC_Payment_Gateway_CC {
|
|||
public function update_option( $key, $value = '' ) {
|
||||
$ret = parent::update_option( $key, $value );
|
||||
|
||||
if ( ! apply_filters( 'woocommerce_paypal_payments_credit_card_gateway_should_update_enabled', true ) ) {
|
||||
return $ret;
|
||||
}
|
||||
|
||||
if ( 'enabled' === $key ) {
|
||||
|
||||
$this->config->set( 'dcc_enabled', 'yes' === $value );
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue