Skip to content

Instantly share code, notes, and snippets.

@bekarice
Created December 23, 2014 02:23
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save bekarice/3a0898f8fa7d834af6eb to your computer and use it in GitHub Desktop.
WooCommerce Checkout Add-ons conditional display
/**
* Conditionally show gift add-ons if shipping address differs from billing
**/
function wc_checkout_add_ons_conditionally_show_gift_add_on() {
wc_enqueue_js( "
$( 'input[name=ship_to_different_address]' ).change( function () {
if ( $( this ).is( ':checked' ) ) {
// show the gift checkout add-on -- replace '2' with the id of your add-on
$( '#wc_checkout_add_ons_2_field' ).show();
} else {
// hide the gift checkout add-on -- replace '2' with the id of your add-on
$( '#wc_checkout_add_ons_2_field' ).hide();
}
} ).change();
" );
}
add_action( 'wp_enqueue_scripts', 'wc_checkout_add_ons_conditionally_show_gift_add_on' );
@schalkjoubert
Copy link

Hi,
I have 2 fields
1: A file upload Field: Please upload your ID.
2: A checkbox field. Please confirm that this is a true copy of your ID

Since ID is optional field, i want the Checkbox to only show if the user uploaded an ID.
Possible?
Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment