Created
July 25, 2019 03:14
-
-
Save KeylorCR/fbc1a0e4012286ea6ef112c25c0338e3 to your computer and use it in GitHub Desktop.
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
/** | |
** 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