Created
December 7, 2017 04:08
Star
You must be signed in to star a gist
Remove checkout field if product IDs exist. WooCommerce / WordPress
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Conditionally remove a checkout field based on products in the cart | |
*/ | |
function wc_ninja_remove_checkout_field( $fields ) { | |
if ( ! wc_ninja_product_is_in_the_cart() ) { | |
unset( $fields['billing']['billing_company'] ); | |
} | |
return $fields; | |
} | |
add_filter( 'woocommerce_checkout_fields' , 'wc_ninja_remove_checkout_field' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment