Created
April 24, 2019 09:57
-
-
Save the7th/8034c3fa2d605dde37a6dd28207fdc8d to your computer and use it in GitHub Desktop.
proof of payment
This file contains hidden or 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
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