I added a custom snippet to my woocommerce site and now I'm having trouble translating the string to Polylang.
I needed the snippet to add a text above the payment methods, and it works fine, it was added via the Code Snippet plugin (https://wordpress.org/plugins/code-snippets/)
add_action( 'woocommerce_review_order_before_payment', 'wc_privacy_message_below_checkout_button' );
function wc_privacy_message_below_checkout_button() {
echo __('<h3>Metodo di pagamento</h3>', 'text-domain');
}
Now I have inserted an additional snippet to add the string to Polylang, but once updated with the translation nothing happens
add_action('init', function() {
pll_register_string('Metodo di pagamento', 'Metodo di pagamento');
});
How can I solve? Is there another way? Thank You
you might try using "pll_e(' " instead of "__(' "
like:
function wc_privacy_message_below_checkout_button() {
pll_e('<h3>Metodo di pagamento</h3>');
}
Furthermore if I recall correctly the string content must be the same as the echoed one:
pll_register_string('the_string_name', '<h3>Metodo di pagamento</h3>');
Then change the string in the Polylang admin page.
If this echoes the "h3" heading tags you can remove them and style the registered string right in Polylang.
You can also try leaving the function as is (how you wrote it) and correcting the string content in the registering code, changing it like this:
pll_register_string('the_string_name', '<h3>Metodo di pagamento</h3>');
I haven't done it inside of a function myself and hope this works for you, but in case it doesn't I still think that "pll_e()" might be what you need.