Skip Navigation

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

This topic contains 1 reply, has 2 voices.

Last updated by Andreas 1 year, 6 months ago.

Assisted by: Andreas.

Author Posts
October 26, 2022 at 12:36 pm #12315359

henrikL-12

I am using a code snippet to hide prices, if the user is not logged in.

It looks like this:
add_filter( 'woocommerce_get_price_html', 'bbloomer_hide_price_addcart_not_logged_in', 9999, 2 );

function bbloomer_hide_price_addcart_not_logged_in( $price, $product ) {
if ( ! is_user_logged_in() ) {
$price = '<div>' . __( 'Log ind for at se priser', 'bbloomer' ) . '</div>';
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 );
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );
}
return $price;
}

I want to translate the line "Log ind for at se priser" (Danish), to "Login to see prices" (English).
The site uses (off course) WPML

October 26, 2022 at 1:26 pm #12315709

Andreas

Hello there

Thank you for contacting us. I am happy to help you.

If the snippet is in theme's function php, please rescan theme to find new strings and then add translation to String Translation.

I am sharing a few docs to read more.

https://wpml.org/documentation/getting-started-guide/string-translation/finding-strings-that-dont-appear-on-the-string-translation-page/

https://wpml.org/documentation/support/enabling-text-translation-for-themes-not-compatible-with-wpml/

I hope this helps. Please let us know how it goes or if you need any further assistance. I'll gladly help you. 🙂

Regards,
Andreas

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.