Skip Navigation

This thread is resolved. Here is a description of the problem and solution.

Problem:
The client is experiencing an issue where multi currency functionality stops working after adding custom PHP code to hide prices for visitors who are not logged in. The URL parameter

&wcmlc=USD

is added, but the price does not change.
Solution:
We do not provide support for custom coding. However, we recommend using WPML's filters and action hooks for proper multilingual support. Here are some resources that might help:

If you require custom work beyond the scope of our support, we suggest contacting WPML Contractors at https://wpml.org/contractors/.

If this solution does not seem relevant to your issue, please feel free to open a new support ticket with us.

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.

Tagged: 

This topic contains 1 reply, has 2 voices.

Last updated by Waqas Bin Hasan 1 year, 6 months ago.

Assisted by: Waqas Bin Hasan.

Author Posts
December 2, 2023 at 7:50 pm #14978753

karolK-12

I have this simple PHP code running which hides prices for visitors (not logged in users):

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>' . __( 'Cena po zalogowaniu', '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 );
add_filter( 'woocommerce_is_purchasable', '__return_false' );
}
return $price;
}

After enabling, multi currency stops working: &wcmlc=USD gets added to the URL, but the price does not change. I have also tried with Woocommerce Wholesale Prices plugin, to see if the error was at my end, but the result was the same. Need solution to this problem.

December 4, 2023 at 11:50 am #14986289

Waqas Bin Hasan
WPML Supporter since 05/2014

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi,

Thank you for contacting the support.

Unfortunately support for custom coding is out of scope of this forum.

However, WPML offers filters and action hooks that can be used in your WordPress theme or plugin to provide correct multilingual support. Browse following resources for more information:

- https://wpml.org/documentation/support/wpml-coding-api/
- https://wpml.org/documentation/support/wpml-coding-api/wpml-hooks-reference/
- https://wpml.org/documentation/support/wpml-coding-api/shortcodes/
- https://wpml.org/faq/how-to-get-current-language-with-wpml/
- https://wpml.org/documentation/support/wpml-tables/
- https://wpml.org/documentation/related-projects/woocommerce-multilingual/wcml-hooks-reference/
- https://wpml.org/documentation/support/

If you need additional custom work, we recommend you contact WPML Contractors at https://wpml.org/contractors/.

Regards.