Ask your WordPress questions! Pay money and get answers fast! (more info)

Change text and heading on tabs for addition information WordPress

  • SOLVED

Hi,

I have set up Woocommerce and set the default language to Dutch. From there I started translating everything to English and German.

Now I want change the text of the tab on the productpage that says 'Additional Informatie' to 'Specificaties'.
Please see http://test.dosator.nl/product/rvs-12l/

How can I change the default text? I cannot find it in the .po file.

I also tried change it using php code in the functions.php file:

/**
* Change on single product panel "Additional Information"
*/
add_filter('woocommerce_product_additional_information_heading',
'isa_product_additional_information_heading');

function isa_product_additional_information_heading() {
echo 'Specificaties';
}


This works but then I can not translate it in WPML.

The last thing I tried was using Woocommerce Customizer. This works as well but same problem as above. I can not translate it in WPML.

Thanks!

Mark

Answers (2)

2013-07-23

Francisco Javier Carazo Gil answers:

Have you tried with it? http://wordpress.org/plugins/woocommerce-multilingual/


Francisco Javier Carazo Gil comments:

This plugins works with WooCommerce and WPML at the same time to solve this kind of problems easily.


Francisco Javier Carazo Gil comments:

You can also use the API of WPML: http://wpml.org/documentation/support/wpml-coding-api/


Francisco Javier Carazo Gil comments:

Something like:

function isa_product_additional_information_heading() {

if(ICL_LANGUAGE_CODE==en)
echo "Specificaties";
else if(ICL_LANGUAGE_CODE==du)
echo "Other thing";
}


markvhussen comments:

Thanks. I rather not use another plugin since this is the only small bit of text that I cannot translate. I'll give the conditional statement a try.


Francisco Javier Carazo Gil comments:

Try the condition it should work, please check the codes you are using to define languages.


markvhussen comments:

I does work. Now I only need to know how change the text in the tab itzelf. Any ideas?


Francisco Javier Carazo Gil comments:

You could do it always with jQuery if you cannot do it directly.


Francisco Javier Carazo Gil comments:

Something like:


function isa_product_additional_information_heading() {
if(ICL_LANGUAGE_CODE==en)
{
echo "Specificaties";
}
else if(ICL_LANGUAGE_CODE==du)
{
echo "Other thing";
echo "<script>jQuery('#id_tab').text('change text');</script>";
}
}


markvhussen comments:

Hmm... not good. The attribute value / specs have disappeared now.


markvhussen comments:

Not sure I understand your jQuery suggestion....


Francisco Javier Carazo Gil comments:

Not, jQuery is not the best here.

Tabs should be prepared and echo in somewhere into your theme, so there, you should make the condition as all should be done.


markvhussen comments:

It changes the same text, the heading instead of the text in the tab.

Please see: http://test.dosator.nl/en/product/rvs-12plus-rvs-24plus/


Francisco Javier Carazo Gil comments:

Are you changing the theme? I don't know what are you doing now exactly.


markvhussen comments:

I am editing the functions.php file.

Furthermore, I am trying to figure out how I can change the text as well.


Francisco Javier Carazo Gil comments:

You have to make the same if but you have to look for this tab in your whole theme, make a search in all files to look for it.


markvhussen comments:

Yes, I am looking in the woocommerce files but cannot find it. Do you have a change to download the woocommerce plugin and findout where?


markvhussen comments:

Yes, I am looking in the woocommerce files but cannot find it. Do you have a change to download the woocommerce plugin and findout where?


Francisco Javier Carazo Gil comments:

You cannot change Woocommerce... you have to make a adaptation into your theme. It is not difficult but long.

2013-07-23

Sabby Sam answers:

it is redirecting to login page


Sabby Sam comments:

I am not sure, why don't you try with conditional statement

http://codex.wordpress.org/Function_Reference/get_locale
etlocale(LC_MONETARY, get_locale());
$my_local_settings = localeconv();
if ($my_local_settings['int_curr_symbol'] == "en_US") {

echo 'Specificaties';
}
else {}


/**

* Change on single product panel "Additional Information"

*/

add_filter('woocommerce_product_additional_information_heading',

'isa_product_additional_information_heading');



function isa_product_additional_information_heading() {

echo 'Specificaties';

}


markvhussen comments:

Sorry, the link should work now. I removed the redirect.

Thanks.


markvhussen comments:

This is probably where it is. No idea how write the statement that will change the title.

<?php
/**
* Single Product tabs
*
* @author WooThemes
* @package WooCommerce/Templates
* @version 2.0.0
*/

if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly

/**
* Filter tabs and allow third parties to add their own
*
* Each tab is an array containing title, callback and priority.
* @see woocommerce_default_product_tabs()
*/
$tabs = apply_filters( 'woocommerce_product_tabs', array() );

if ( ! empty( $tabs ) ) : ?>

<div class="woocommerce-tabs">
<ul class="tabs">
<?php foreach ( $tabs as $key => $tab ) : ?>

<li class="<?php echo $key ?>_tab">
<a href="#tab-<?php echo $key ?>"><?php echo apply_filters( 'woocommerce_product_' . $key . '_tab_title', $tab['title'], $key ) ?></a>
</li>

<?php endforeach; ?>
</ul>
<?php foreach ( $tabs as $key => $tab ) : ?>

<div class="panel entry-content" id="tab-<?php echo $key ?>">
<?php call_user_func( $tab['callback'], $key, $tab ) ?>
</div>

<?php endforeach; ?>
</div>

<?php endif; ?>


Sabby Sam comments:

Between this you can write the code
<li class="<?php echo $key ?>_tab">

<a href="#tab-<?php echo $key ?>"><?php echo apply_filters( 'woocommerce_product_' . $key . '_tab_title', $tab['title'], $key ) ?></a>

</li>