Add the JQuery code below in Snippets
-
Hi,
I try to add the JQuery code below in Snippets, but it will get fatal error. Can i ask, how can i properly add the code below in Snippets?
jQuery(function(){
jQuery( ‘body’ )
.on( ‘updated_checkout’, function() {
usingGateway();jQuery(‘input[name=”payment_method”]’).change(function(){
console.log(“payment method changed”);
usingGateway();});
});
});function usingGateway(){
console.log(jQuery(“input[name=’payment_method’]:checked”).val());
if(jQuery(‘form[name=”checkout”] input[name=”payment_method”]:checked’).val() == ‘cod’){
jQuery(‘.woocommerce-billing-fields #billing_company_field, .woocommerce-billing-fields #billing_country_field, .woocommerce-billing-fields #billing_address_1_field, .woocommerce-billing-fields #billing_address_2_field, .woocommerce-billing-fields #billing_city_field, .woocommerce-billing-fields #billing_state_field, .woocommerce-billing-fields #billing_postcode_field, .woocommerce-shipping-fields’).hide();
//Etc etc
} else {
jQuery(‘.woocommerce-billing-fields #billing_company_field, .woocommerce-billing-fields #billing_country_field, .woocommerce-billing-fields #billing_address_1_field, .woocommerce-billing-fields #billing_address_2_field, .woocommerce-billing-fields #billing_city_field, .woocommerce-billing-fields #billing_state_field, .woocommerce-billing-fields #billing_postcode_field, .woocommerce-shipping-fields’).show();
}
}
- The topic ‘Add the JQuery code below in Snippets’ is closed to new replies.