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
|
@ -394,6 +394,23 @@ class SettingsModule implements ServiceModule, ExecutableModule {
|
||||||
2
|
2
|
||||||
);
|
);
|
||||||
|
|
||||||
|
add_filter(
|
||||||
|
'woocommerce_paypal_payments_credit_card_gateway_form_fields',
|
||||||
|
function( array $form_fields ) {
|
||||||
|
$form_fields['enabled'] = array(
|
||||||
|
'title' => __( 'Enable/Disable', 'woocommerce-paypal-payments' ),
|
||||||
|
'type' => 'checkbox',
|
||||||
|
'desc_tip' => true,
|
||||||
|
'description' => __( 'Once enabled, the Credit Card option will show up in the checkout.', 'woocommerce-paypal-payments' ),
|
||||||
|
'label' => __( 'Enable Advanced Card Processing', 'woocommerce-paypal-payments' ),
|
||||||
|
'default' => 'no',
|
||||||
|
);
|
||||||
|
|
||||||
|
return $form_fields;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
add_filter( 'woocommerce_paypal_payments_credit_card_gateway_should_update_enabled', '__return_false' );
|
||||||
|
|
||||||
add_filter(
|
add_filter(
|
||||||
'woocommerce_paypal_payments_credit_card_gateway_title',
|
'woocommerce_paypal_payments_credit_card_gateway_title',
|
||||||
function( string $title, WC_Payment_Gateway $gateway ) {
|
function( string $title, WC_Payment_Gateway $gateway ) {
|
||||||
|
|
|
@ -279,9 +279,9 @@ class CreditCardGateway extends \WC_Payment_Gateway_CC {
|
||||||
'woocommerce-paypal-payments'
|
'woocommerce-paypal-payments'
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->title = apply_filters( 'woocommerce_paypal_payments_credit_card_gateway_title', $this->dcc_configuration->gateway_title(), $this );
|
$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->description = apply_filters( 'woocommerce_paypal_payments_credit_card_gateway_description', $this->dcc_configuration->gateway_description(), $this );
|
||||||
$this->card_icons = $card_icons;
|
$this->card_icons = $card_icons;
|
||||||
|
|
||||||
$this->init_form_fields();
|
$this->init_form_fields();
|
||||||
$this->init_settings();
|
$this->init_settings();
|
||||||
|
@ -299,10 +299,13 @@ class CreditCardGateway extends \WC_Payment_Gateway_CC {
|
||||||
* Initialize the form fields.
|
* Initialize the form fields.
|
||||||
*/
|
*/
|
||||||
public function init_form_fields() {
|
public function init_form_fields() {
|
||||||
$this->form_fields = array(
|
$this->form_fields = apply_filters(
|
||||||
'ppcp' => array(
|
'woocommerce_paypal_payments_credit_card_gateway_form_fields',
|
||||||
'type' => 'ppcp',
|
array(
|
||||||
),
|
'ppcp' => array(
|
||||||
|
'type' => 'ppcp',
|
||||||
|
),
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -583,6 +586,10 @@ class CreditCardGateway extends \WC_Payment_Gateway_CC {
|
||||||
public function init_settings() {
|
public function init_settings() {
|
||||||
parent::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.
|
// looks like in some cases WC uses this field instead of get_option.
|
||||||
$this->enabled = $this->is_enabled() ? 'yes' : '';
|
$this->enabled = $this->is_enabled() ? 'yes' : '';
|
||||||
}
|
}
|
||||||
|
@ -595,6 +602,10 @@ class CreditCardGateway extends \WC_Payment_Gateway_CC {
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function get_option( $key, $empty_value = null ) {
|
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 ) {
|
if ( 'enabled' === $key ) {
|
||||||
return $this->is_enabled();
|
return $this->is_enabled();
|
||||||
}
|
}
|
||||||
|
@ -612,6 +623,10 @@ class CreditCardGateway extends \WC_Payment_Gateway_CC {
|
||||||
public function update_option( $key, $value = '' ) {
|
public function update_option( $key, $value = '' ) {
|
||||||
$ret = parent::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 ) {
|
if ( 'enabled' === $key ) {
|
||||||
|
|
||||||
$this->config->set( 'dcc_enabled', 'yes' === $value );
|
$this->config->set( 'dcc_enabled', 'yes' === $value );
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue