How to remove the credit card info from a shopping cart when a promo code gives a 100% discount

We’ve heard about special code we can put into the shopping cart so that when a user enters a 100% off promo code the credit card fields either disappear or are no longer mandatory.

Does anyone have any insight into this?

Thank you!