Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.
Closed 5 years ago.
Improve this questionI added this function to add cash on delivery price and I want to translate the text (cash on delivery) using WPML plugin
add_action( 'woocommerce_cart_calculate_fees', 'custom_handling_fee', 10, 1 );
function custom_handling_fee ( $cart ) {
if ( is_admin() && ! defined( 'DOING_AJAX' ) )
return;
if ( 'cod' === WC()->session->get('chosen_payment_method') ) {
$fee = 10;
$cart->add_fee( 'Cash On Delivery', $fee, true );
}
}
Closed. This question is off-topic. It is not currently accepting answers.
Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.
Closed 5 years ago.
Improve this questionI added this function to add cash on delivery price and I want to translate the text (cash on delivery) using WPML plugin
add_action( 'woocommerce_cart_calculate_fees', 'custom_handling_fee', 10, 1 );
function custom_handling_fee ( $cart ) {
if ( is_admin() && ! defined( 'DOING_AJAX' ) )
return;
if ( 'cod' === WC()->session->get('chosen_payment_method') ) {
$fee = 10;
$cart->add_fee( 'Cash On Delivery', $fee, true );
}
}
Share
Improve this question
edited Nov 23, 2019 at 19:57
fuxia♦
107k39 gold badges255 silver badges459 bronze badges
asked Nov 13, 2019 at 7:25
bsomarbsomar
133 bronze badges
1 Answer
Reset to default 1It should suffice to add a __()
around your translatable text:
add_action( 'woocommerce_cart_calculate_fees', 'custom_handling_fee', 10, 1 );
function custom_handling_fee ( $cart ) {
if ( is_admin() && ! defined( 'DOING_AJAX' ) )
return;
if ( 'cod' === WC()->session->get('chosen_payment_method') ) {
$fee = 10;
$cart->add_fee( __('Cash On Delivery'), $fee, true );
}
}
You can then scan your theme or plugin for strings in WPML: https://wpml/documentation/getting-started-guide/theme-localization/ and then use the WPML string translation.