Add JQuery As Code Snippet

I would like to add jquery code snippet for Woocommerce checkout page for a specific product in the cart, but I’m confused on how to adapt the code to wordpress. Any ideas? Here is the code:

add_action( ‘woocommerce’);
function woocommerce() {
$product_id = 18; // a specific product ID you would like to check
if( WC()->cart->find_product_in_cart( WC()->cart->generate_cart_id(
$product_id ) ) ) {

<!– JQuery Code –>
<script type=”text/javascript”>
var jq = jQuery.noConflict();
jq(window).load(function(){
jq(‘#email’).on(‘input’, function() {
jq( “div.tip” ).show();
jq( “#h2” ).show();
});
jq(‘div.tip’).hide();
jq( “#h2” ).hide();
});
</script>
<!– JQuery Code –>

}
}

Read more here:: Add JQuery As Code Snippet

Leave a Reply

Your email address will not be published. Required fields are marked *