Skip to content

Instantly share code, notes, and snippets.

@the7th
Created April 24, 2019 09:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save the7th/8034c3fa2d605dde37a6dd28207fdc8d to your computer and use it in GitHub Desktop.
Save the7th/8034c3fa2d605dde37a6dd28207fdc8d to your computer and use it in GitHub Desktop.
proof of payment
add_action( 'woocommerce_checkout_order_review', 'method_proof_of_payment', 10, 1 );
add_action( 'woocommerce_checkout_order_review', 'check_order', 10, 1 );
function method_proof_of_payment() {
echo "<script>
jQuery( document ).ajaxComplete(function() {
if(jQuery('#payment_method_cod').is(\":checked\")){
jQuery('label[for=\"wccf_checkout_field_proof_payment\"]').show();
jQuery('#wccf_checkout_field_proof_payment').show();
} else {
jQuery('label[for=\"wccf_checkout_field_proof_payment\"]').hide();
jQuery('#wccf_checkout_field_proof_payment').hide();
}
});
</script>";
}
function check_order() {
echo "
<script>
jQuery(document).ready(function($) {
jQuery(\"form.woocommerce-checkout\").on('submit', function(event) {
if(jQuery('#payment_method_cod').is(\":checked\")){
if( document.getElementById(\"wccf_checkout_field_proof_payment\").files.length == 0 ){
event.preventDefault();
alert(\"Please insert payment proof\");
}
}
});
});</script>";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment