Panoramica del problema
Quando usi Mollie Payments for WooCommerce con WPML, potresti riscontrare il seguente problema: i titoli e le descrizioni dei metodi di pagamento che traduci in WPMLTraduzione stringhe appaiono nella lingua predefinita nel checkout delle lingue secondarie (Mollie 8.0 e versioni successive).
Soluzione alternativa
Aggiungi questo codice al file functions.php del tuo tema. Traduce il titolo e la descrizione del checkout a blocchi; la descrizione nel checkout classico non ha una soluzione alternativa:
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 );