Shortcode created to check language not works

i need to create a shortcode to display a different Div depending on WP current language only when users are logout.

The shortcode is this one:

function coupon_box() {

$user = is_user_logged_in() ;

if ($user == false) {

if (get_locale() == ‘en_Us’) {
echo ‘ <div class=”discount”><h3 style=”text-align: left;”>Is this your first order?</h3><p style=”text-align: left;”>Request your discount code for a value of 20 euros.</p><p style=”text-align: left;”><span style=”text-decoration: underline;”><a class=”myButton” href=”https://www.atremoplus.net/welcome-coupon/”>Receive my code
</a></span></p></div>’;
}

elseif (get_locale() == ‘fr_Fr’) {

echo ‘<div class=”discount”><h3 style=”text-align: left;”>C’est votre première commande?</h3><p style=”text-align: left;”>Demandez votre code de réduction d’une valeur de 20 Euros.</p><p style=”text-align: left;”><span style=”text-decoration: underline;”><a class=”myButton” href=”https://atremoplus.fr/bienvenue/”>Recevoir mon code</a></span></p></div>’;
}

elseif (get_locale() == ‘de_De’) {
echo ‘<div class=”discount”><h3 style=”text-align: left;”>Ist dies Ihre erste Bestellung?</h3><p style=”text-align: left;”> Fordern Sie Ihren persönlichen 20 Euros Rabatt.</p><p style=”text-align: left;”><span style=”text-decoration: underline;”><a class=”myButton” href=”https://www.atremoplus.net/de/atremoplus-kaufen/”>Gutscheincode anfordern</a></span></p></div>’;
}

else {

echo ‘<div class=”discount”><h3 style=”text-align: left;”> ¿Este es su primer pedido?</h3><p style=”text-align: left;”> Solicite su código de descuento por un valor de 20 euros.</p><p style=”text-align: left;”><span style=”text-decoration: underline;”><a class=”myButton” href=”https://www.atremoplus.net/es/comprar-atremoplus/”>Recibir mi código</a></span></p></div>’;
}
}

}

add_shortcode(‘coupon’, ‘coupon_box’);

Is there something you see that is wrong please?

Thank you!

Read more here:: Shortcode created to check language not works

Leave a Reply

Your email address will not be published. Required fields are marked *