Done !
| Server IP : 162.240.50.153 / Your IP : 216.73.216.201 Web Server : Apache System : Linux vps-880082.mktpower.cl 3.10.0-1160.119.1.el7.tuxcare.els25.x86_64 #1 SMP Wed Oct 1 17:37:27 UTC 2025 x86_64 User : wwmktp ( 1003) PHP Version : 8.3.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/wwmktp/.trash/ |
Upload File : |
<?php
/**
* Aplica Select2 al campo shipping_state en el checkout de WooCommerce.
*/
add_action( 'wp_footer', 'fix_shipping_state_select2', 99 );
function fix_shipping_state_select2() {
if ( ! function_exists( 'is_checkout' ) || ! is_checkout() ) {
return;
}
?>
<script>
jQuery( function( $ ) {
function initShippingStateSelect2() {
var $select = $( '#shipping_state' );
if ( ! $select.length || $select.is( ':hidden' ) ) return;
// Destruir instancia previa si existe
if ( $select.hasClass( 'select2-hidden-accessible' ) ) {
$select.select2( 'destroy' );
}
$select.select2( {
placeholder: 'Elige una opción…',
allowClear: true,
width: '100%',
language: {
noResults: function() { return 'No se encontraron resultados'; },
searching: function() { return 'Buscando…'; }
}
} );
}
initShippingStateSelect2();
// Usar un flag para evitar loops
var updating = false;
$( document.body ).on( 'updated_checkout', function() {
if ( updating ) return;
updating = true;
setTimeout( function() {
initShippingStateSelect2();
updating = false;
}, 300 );
} );
} );
</script>
<?php
}