• Resolved jmoutsounis

    (@jmoutsounis)


    Is this possible?

    I’d like to hide it for free products like how the Stripe payment gateway does not appear when only free products are in the cart.

    Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support Jeff Alvarez

    (@superlemon1998)

    hi @jmoutsounis,

    We currently do not have that feature, for the free products are you perhaps using a 3rd party plugin to give the free products? If yes, please reach out to their support team.

    If you are say creating a product and setting the price to 0 then. You can add the snippet to your child theme’s functions.php or through the WPCode plugin

    The snippet will stop the invoice payment gateway if the customer’s cart only haves free product(0 in price) in their cart. If there’s shipping fees, invoice will still be hidden as there is not product of value

     add_action('woocommerce_available_payment_gateways','Stop_Payment_Gateway',9999);
    
     function Stop_Payment_Gateway($available_gateways){
    	 if(is_cart() || is_checkout()){
    	 $total= WC()->cart->get_subtotal();
    	 
    	if($total > 0 ){
    		//return nothing
    	}else{
    		unset($available_gateways['igfw_invoice_gateway']); // Add the payment Code ID here
    	}
     
     }
    	 
    	 return $available_gateways;
     
     }
     
    Thread Starter jmoutsounis

    (@jmoutsounis)

    Hi Jeff,

    That worked well, thank you, but I’ve recently found that if you use a coupon code at cart or checkout to make a product free e.g. 100% discount, the gateway doesn’t get hidden.

    Is there a possible tweak to your code snippet to cater for this too?

    Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Hide ‘Request an invoice’ for free products on checkout’ is closed to new replies.