Comment supprimer d'autres pays du formulaire d'inscription

Par défaut, nous n’avons pas de fonctionnalité pour supprimer d’autres pays dans la liste déroulante des pays de la page d’inscription de gros.

Heureusement, il existe une solution simple en utilisant l’extrait personnalisé ci-dessous et en l’ajoutant au fichier functions.php de votre thème/thème enfant.

// Change the country list of the registration form
add_filter( 'woocommerce_form_field_args', 'my_wwlc_set_country');
function my_wwlc_set_country($args){
// Set the country list
if($args['id'] == 'wwlc_country'){
$args['options'] = array(
'AU' => 'Australia',
'US' => 'United States'
);
}
// Return the modified list
return $args;
}
Please note that the code above needs to use the correct 2 digit country code. For example, ‘AU’ for Australia, and 'US' for United States. You can replace or add more countries by following that format. Kindly visit this link to get the list of 2-digit country codes.

De plus, parfois l’état ou les provinces ne se chargent pas automatiquement lorsque vous supprimez d’autres pays. Le code ci-dessous peut être ajouté pour charger l’état automatiquement.

add_action( 'wp_footer' , function() {
    global $post;
    if( ( isset( $post->post_content ) && has_shortcode( $post->post_content , 'wwlc_registration_form' ) ) ) { ?>
    <script type="text/javascript">
        jQuery(document).ready(function(){
            jQuery("#wwlc_country").trigger("change");
        });
    </script>
    <?php }
}, 100 );
Cet article vous a-t-il été utile ?

Articles liés

Besoin de support ?

Vous ne trouvez pas la réponse que vous cherchez ?
Contacter le support
Finalisez votre achat