Skip to content

Instantly share code, notes, and snippets.

@tamarazuk
Last active August 30, 2019 04:06
Show Gist options
  • Save tamarazuk/88c6574a110f04db5515 to your computer and use it in GitHub Desktop.
Save tamarazuk/88c6574a110f04db5515 to your computer and use it in GitHub Desktop.
WooCommerce Checkout Add-ons - Enable WPML translation of labels, names, and options
<?php
function sv_wc_checkout_add_ons_wpml_translate( $label ) {
return apply_filters( 'translate_string', $label, 'woocommerce-checkout-add-ons', $label );
}
add_filter( 'woocommerce_checkout_add_on_get_name', 'sv_wc_checkout_add_ons_wpml_translate' );
add_filter( 'woocommerce_checkout_add_on_get_label', 'sv_wc_checkout_add_ons_wpml_translate' );
function sv_wc_checkout_add_ons_options_wpml_translate( $options ) {
$translated_options = array();
foreach ( $options as $option ) {
$option['label'] = apply_filters( 'translate_string', $option['label'], 'woocommerce-checkout-add-ons', $option['label'] );
$translated_options[] = $option;
}
return $translated_options;
}
add_filter( 'woocommerce_checkout_add_on_get_options', 'sv_wc_checkout_add_ons_options_wpml_translate' );
@forlini
Copy link

forlini commented Oct 8, 2015

Can't get them to register, do I need to change something in the functions file?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment