2

I have a free product on woocommerce. But the stripe payment gateway ask for credit card payment even if it is free with a total of 0€. User can’t checkout without filling the stripe cc form.

Credit card info are not necessary when the product is for free.

I am sure I am not the only one on earth who add some free product in a woocommerce shop. How can I hide this "credticard form" in the check out page in order to let my members access to my free product? Do you know any plugin or hack?

Thanks

LoicTheAztec
  • 229,944
  • 23
  • 356
  • 399
Gauthier Buttez
  • 1,005
  • 1
  • 16
  • 40
  • this example can easily be adapted to meet your question https://businessbloomer.com/woocommerce-disable-payment-method-for-specific-category/ if you still can't figure it out, adjust your question and add the code you've tried so far. – 7uc1f3r Apr 08 '20 at 16:19

1 Answers1

6

Updated: You can use the following to disable checkout payment when there is only free products in cart:

add_filter( 'woocommerce_cart_needs_payment', 'filter_cart_needs_payment_callback', 100, 2 );
function filter_cart_needs_payment_callback( $needs_payment, $cart ) {
    return $cart->subtotal > 0 ? $needs_payment : false;
}

Code goes in function.php file of your active child theme (or active theme). Tested and works.

LoicTheAztec
  • 229,944
  • 23
  • 356
  • 399