Skip to content

Instantly share code, notes, and snippets.

@rayflores
Created June 6, 2014 05:31
Show Gist options
  • Save rayflores/b2def4764b73fda8056d to your computer and use it in GitHub Desktop.
Save rayflores/b2def4764b73fda8056d to your computer and use it in GitHub Desktop.
<?php
/**
* Add checkbox field to the checkout
**/
add_action('woocommerce_after_checkout_billing_form', 'my_custom_checkout_field');
function my_custom_checkout_field( $checkout ) {
add_filter ('add_to_cart_redirect', 'woo_redirect_to_checkout');
echo '<div id="my-new-field"><h3>'.__('1st Time Student?').'</h3>';
echo '<input id="my_checkbox" type="checkbox" class="input-checkbox" value="1" data-target="http://www.experiumscienceacademy.com/newsite/?add-to-cart=6319"/><label for="my_checkbox" class="checkbox ">Yes!</label>';
echo '<input id="my_checkbox_2" type="checkbox" class="input-checkbox_2"/><label for="my_checkbox_no" class="checkbox ">No</label>';
echo '<script>jQuery(function($){
$("input#my_checkbox").change(function(){
var item=$(this);
if(item.is(":checked"))
{
window.location.href=(item.data("target"))
}
});
});</script></div>';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment