Polylang and woocommerce: How to translate currency symbol - woocommerce

i want when i change the language to change my currency symbol. For example, to switch from dollar to euro but without changing numbers ...
Tnx

If you haven't already solved this you may look at this code, provide by WPML.
add_filter('woocommerce_currency_symbol', 'change_existing_currency_symbol', 10, 2);
function change_existing_currency_symbol( $currency_symbol, $currency ) {
switch( $currency ) {
case 'AED':
// if(ICL_LANGUAGE_CODE=='en'){
$currency_symbol = 'AED';
//}else{
// $currency_symbol = 'د.إ';
//}
break;
}
return $currency_symbol;
}

Related

Woo-commerce Changing the default weight unit text from kg to kiloGrams and display kilograms in product page and in additional information

Hey I'm trying to change the weight unit text from kg to kiloGrams in additional information at product page but the code is working for Description string to change but not for working for kg text can't figure out why.
would be really great if anyone could suggest. Thanks.
add_filter( 'gettext', 'bbloomer_translate_woocommerce_strings', 999, 3 );
function bbloomer_translate_woocommerce_strings( $translated, $untranslated, $domain ) {
if ( ! is_admin() && 'woocommerce' === $domain ) {
switch ( $translated) {
case 'g' :
$translated = 'grams';
break;
case 'Description' :
$translated = 'Product Specifications';
break;
// ETC
}
}
return $translated;
}
// To update the units in woocommerce from g to grams or another
update_option( 'woocommerce_weight_unit', 'grams' );

Woocommerce / wpml add different version of same currency

I use WooCommerce & WPML for my client. The website have different prices for different markets.
For example, the EU is a price and for Finland there is another price both in €.
I have included a separate version of currency called FI-EUR. Everything appears right and works just the way I want.
add_filter( 'woocommerce_currencies', 'finland_euro' );
function finland_euro( $currencies ) {
$currencies['FI-EUR'] = __( 'Finland Euro', 'woocommerce' );
return $currencies;
}
add_filter('woocommerce_currency_symbol', 'add_my_currency_symbol', 10, 2);
function add_my_currency_symbol( $currency_symbol, $currency ) {
switch( $currency ) {
case 'FI-EUR': $currency_symbol = '€'; break;
}
return $currency_symbol;
}
But the problem arises when we use Stripe or Paypal. Since it does not support FI-EUR. How do I change FI-EUR to EUR for stripe?
I can not overwrite EUR as there is another price.
Thank you!

Disabinge woocommerce variable product price doesn't work

I tried several codes to disable the price in product variable in woocommerce.
I've tried this but nothing happened:
/*
Disable Variable Product Price Range completely:
*/
add_filter( 'woocommerce_variable_sale_price_html','my_remove_variation_price', 10, 2 );
add_filter( 'woocommerce_variable_price_html', 'my_remove_variation_price', 10, 2 );
function my_remove_variation_price( $price ) {
$price = '';
return $price;
}
I put it in functions.php but nothing happened.
My theme is saha from theme-junkie.
Best way would be to hook into woocommerce_get_price_html filter.
It passes $price HTML and WC_Product* object. You can check if it is instance of WC_Product_Variable to determine if it is a variable product. Then just return '' empty string if it is. This will handle the price display for parent Variable product.
Example
add_filter('woocommerce_get_price_html', 'mm_handle_variation_prices', 10, 2);
function mm_handle_variation_prices( $price_html, $product_obj ){
// Bail unless we are on WooCommerce page on frontend and this is an ajax request.
if( is_admin() || is_ajax() || ! is_woocommerce() ) {
return $price_html;
}
// If this is an Variable product only then return empty string.
// '$product_obj instanceof WC_Product_Variable' check would work as well.
if( 'variable' === $product_obj->get_tyepe() ) {
return '';
} else {
return $price_html;
}
}

Change label on default Wordpress "Lost password page"

I'm trying to change the default label for the Wordpress lost password form which says "Username or E-mail". I need it to just read "Email" and I don't want to edit any core Wordpress files. I've already achieved this for the default login form using:
global $pagenow;
if ($pagenow==='wp-login.php') {
add_filter( 'gettext', 'user_email_login_text', 20, 3 );
function user_email_login_text( $translated_text, $text, $domain ) {
if ($translated_text === 'Username') {
echo $translated_text;
$translated_text = 'Email';
}
return $translated_text;
}
}
And this seems to also work on the other default forms for labels consisting of single words. However, if I augment the if condition to include | $translated_text === 'Username or e-mail' it doesn't work.
Any ideas? I really don't want to have to code a bespoke form as this doesn't fit in with how my system works.
Also, I wonder why Wordpress spells "Email" as "E-mail" on the lost password form, but without the dash on all other forms...
I dont know if you allready solved this. Anyway your code is allmost correct. You were only missing that the string is case sensitive and to include the colon. Like this: if ($translated_text === 'Username or E-mail:')
No need to echo $translated_text either
This works on my installation:
global $pagenow;
if ($pagenow==='wp-login.php') {
add_filter( 'gettext', 'user_email_login_text', 20, 3 );
function user_email_login_text( $translated_text, $text, $domain ) {
if ($translated_text === 'Username or E-mail:') {
$translated_text = 'Email';
}
return $translated_text;
}
}

Wordpress change default translation

I want to change the translation value of a text when the language is the default English USA locale.
What is the correct way to accomplish this so we don't have to change the file every time we upgrade the wordpress version?
This is a nice plugin that does just that: http://wordpress.org/plugins/quick-localization/
But if you have only a few, you can also use this code:
function filter_gettext($translation, $text, $domain) {
if ( $text == 'Recent Comments' ) {
$translations = &get_translations_for_domain( $domain );
return $translations->translate( 'Something else' );
}
return $translation;
}
add_filter('gettext', 'filter_gettext', 10, 4);

Resources