WPML

Overview of the Issue

When using Mollie Payments for WooCommerce with WPML, you might experience the following issue: the payment method titles and descriptions you translate in WPMLString Translation appear in the default language on the checkout of secondary languages (Mollie 8.0 and later).

Workaround

Add this code to your theme’s functions.php file. It translates the title and the block checkout description; the description on the classic checkout has no workaround:

PHP
$wpml_mollie_text = function ( $incoming, $gateway_id, $key ) {
  if ( 0 !== strpos( (string) $gateway_id, 'mollie_wc_gateway_' ) ) { return $incoming; }
  $settings = get_option( $gateway_id . '_settings', [] );
  $original = is_array( $settings ) ? ( $settings[ $key ] ?? '' ) : '';
  if ( ! is_string( $original ) || '' === $original ) { return $incoming; }
  $t = apply_filters( 'wpml_translate_single_string', $original, 'admin_texts_woocommerce_gateways', $gateway_id . '_gateway_' . $key, apply_filters( 'wpml_current_language', null ) );
  return is_string( $t ) && $t !== $original ? $t : $incoming;
};
add_filter( 'woocommerce_gateway_title', function ( $v, $id = '' ) use ( $wpml_mollie_text ) { return $wpml_mollie_text( $v, $id, 'title' ); }, 20, 2 );
add_filter( 'woocommerce_gateway_description', function ( $v, $id = '' ) use ( $wpml_mollie_text ) { return $wpml_mollie_text( $v, $id, 'description' ); }, 20, 2 );
add_filter( 'inpsyde_payment_gateway_blocks_data', function ( $data, $id, $gateway ) use ( $wpml_mollie_text ) {
  if ( isset( $data['content'] ) && is_string( $data['content'] ) ) { $data['content'] = $wpml_mollie_text( $data['content'], $id, 'description' ); }
  return $data;
}, 20, 3 );

All known issues

Need Help with This Issue?

Ask a support question and we’ll look into it with you.