(Variations & Quantity) Simple Products – hide Stripe (or other) CC payment fields when a free $0 product is selected

You are using “Variations & Quantity” feature in “Simple Products” mode, that allows your customers to pick one of the multiple products right on the checkout page.

And one of those products is free. Then by default payments fields to enter credit card details might be hidden and won’t show up, even if paid product is selected instead.

This code below should work for any other card gateways, not only Stripe.

This code below will trigger checkout page to load all scripts required to process a payment, even if current cart total equals 0 (free product selected). And payment fields to enter CC details will only show up, when a paid product is selected.

Put this snippet into functions.php of your theme: