skip to Main Content

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?

2

Answers


  1. 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.

    Login or Signup to reply.
  2. 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;
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search