Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
/**
** After update checkout
**/
$(document.body).on('update_checkout, updated_checkout', function () {
validate_checkout_required_fields();
});
function validate_checkout_required_fields() {
if($('select.shipping_method').val() == "wc_pickup_store") {
$('#billing_state_field, #billing_city_field, #billing_address_1_field').find(".required").hide();
$('#billing_state_field, #billing_city_field, #billing_address_1_field').removeClass("validate-required woocommerce-validated woocommerce-invalid woocommerce-invalid-required-field");
} else {
if($('#billing_state_field .required, #billing_city_field .required, #billing_address_1_field .required').length < 1) {
$('#billing_state_field label, #billing_city_field label, #billing_address_1_field label').append('<abbr class="required" title="obligatorio">*</abbr>');
} else {
$('#billing_state_field, #billing_city_field, #billing_address_1_field').find(".required").show();
}
$('#billing_state_field, #billing_city_field, #billing_address_1_field').addClass("validate-required");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment