Skip to content

Instantly share code, notes, and snippets.

@KoolPal
Created October 1, 2019 05:51
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KoolPal/ba0dce676b522fd8a202c70de0956ff6 to your computer and use it in GitHub Desktop.
Save KoolPal/ba0dce676b522fd8a202c70de0956ff6 to your computer and use it in GitHub Desktop.
Retain Quote Billing & Shipping Country ELSE assign Location based on IP (Geolocation)
// 06-05-2019 Retain Quote Billing & Shipping Country ELSE assign Location based on IP (Geolocation)
function remove_checkout_optional_fields_label_script() {
// Only on checkout page
if( ! ( is_checkout() && ! is_wc_endpoint_url() ) ) return;
$optional = '&nbsp;<span class="optional">(' . esc_html__( 'optional', 'woocommerce' ) . ')</span>';
?>
<script>
jQuery(function($){
// On "update" checkout form event remove option to select countries
$(document.body).on('update_checkout', function(){
$('#billing_country_field label > .optional').remove();
$('.woocommerce-checkout #billing_country_field').css('pointer-events', 'none');
$('#shipping_country_field label > .optional').remove();
$('.woocommerce-checkout #shipping_country_field').css('pointer-events', 'none');
});
});
</script>
<?php
}
add_filter( 'wp_footer' , 'remove_checkout_optional_fields_label_script' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment