-
AuthorPosts
-
February 16, 2023 at 10:10 pm #153194
CHROMATOTEC CHROMATOTECParticipantHello, I must rethink my use of curcy following a change in my direction.
I have to add currency according to the roles and not to the languages, I tried to make a code to add it in the snippet pluggin but my code doesn’t work, how can I solve it?
i think the filter curcy_currency dosen’t exist but i don’t find any information in your documentation
here is my code :// Ajouter une action pour d茅finir les devises en fonction des r么les utilisateur
add_filter( ‘curcy_currency’, ‘changer_devises_par_role’ );function changer_devises_par_role( $currency ) {
// V茅rifier si l’utilisateur est connect茅
if ( is_user_logged_in() ) {
// R茅cup茅rer l’ID du r么le de l’utilisateur actuel
$user = wp_get_current_user();
$roles = ( array ) $user->roles;
$role = $roles[0]; // Le premier r么le est le plus prioritaire// D茅finir les devises disponibles en fonction du r么le de l’utilisateur
switch ( $role ) {
case ‘Clients_EU_FR’:
$currency = ‘EUR’;
break;
case ‘Clients_Usa’:
$currency = ‘USD’;
break;
case ‘Clients_asia’:
$currency = ‘CNY’; // Utiliser le code de devise ISO 4217 pour le RMB (Yuan chinois)
break;
default:
$currency = ‘EUR’; // D茅finir la devise Euro par d茅faut pour les autres r么les
break;
}
}
return $currency;
}Cordially 馃檪
-
AuthorPosts
You must be logged in to see replies to this topic. Click here to login or register