0

I have added a checkbox in Woocommerce checkout with this

add_action( 'woocommerce_before_checkout_form', 'add_checkout_checkbox', 10 );
function bt_add_checkout_checkbox() {
$maximum = 200;
if ( WC()->cart->total > $maximum ) {
woocommerce_form_field( 'checkout-checkbox', array(
'type'          => 'checkbox',
'class'         => array('form-row mycheckbox'),
'label_class'   => array('woocommerce-form__label woocommerce-form__label-for-checkbox checkbox'),
'input_class'   => array('woocommerce-form__input woocommerce-form__input-checkbox input-checkbox'),
'required'      => false,
'label'         => 'Lorem ipsum',
 ));    
 }}

I need to disable the payment method PayPal if this checkbox is NOT checked. If it is checked, PayPal should be enabled. How do I need to adapt my code/add to it?

rogerk
  • 43
  • 5

2 Answers2

1

let put this code in function.php

add_filter('woocommerce_available_payment_gateways','filter_gateways',1);
function filter_gateways($gateways){
    global $woocommerce;        
    //Remove a specific payment option
    unset($gateways['paypal']);
    return $gateways;
}
habib
  • 11
  • 2
0

Hi you can be done by disabling the PayPal Mark option within WooCommerce > Settings > Checkout > PayPal Express Checkout settings page.Uncheck the option to Enable the PayPal Mark on regular checkout and it will be removed from the checkout page.

habib
  • 11
  • 2
  • @habb Please read my question carefully. I need to only remove PayPal if the checkbox I added is NOT checked by the customer. If the checkbox is checked, PayPal still needs to be available. – rogerk Sep 24 '20 at 08:11