Panoramica del problema
Quando usi Deposits & Partial Payments for WooCommerce con WPML, potresti riscontrare i seguenti problemi: un prodotto tradotto non ottiene le impostazioni di deposito del prodotto stesso e l’e-mail di “pagamento del deposito ricevuto” arriva al cliente nella lingua predefinita.
Soluzione alternativa
Vai a WPMLImpostazioni e aggiungi quanto segue alla Configurazione XML personalizzata:
<custom-fields>
<custom-field action="copy">_awcdp_deposit_enabled</custom-field>
<custom-field action="copy">_awcdp_deposit_type</custom-field>
<custom-field action="copy">_awcdp_deposits_deposit_amount</custom-field>
</custom-fields>
<admin-texts>
<key name="woocommerce_awcdp_deposit_paid_settings">
<key name="subject" />
<key name="heading" />
<key name="email_text" />
<key name="payment_text" />
</key>
</admin-texts>Quindi traduci i testi delle e-mail in WPMLTraduzione stringhe e aggiungi il seguente codice al file functions.php del tuo tema child, in modo che il testo dell’e-mail e il testo del pagamento utilizzino la lingua dell’ordine:
PHP
add_filter( 'woocommerce_email_get_option', function ( $value, $email, $old, $key ) {
if ( 'awcdp_deposit_paid' !== $email->id || ! in_array( $key, [ 'email_text', 'payment_text' ], true ) ) {
return $value;
}
if ( empty( $email->object ) || ! is_a( $email->object, 'WC_Order' ) ) {
return $value;
}
$lang = $email->object->get_meta( 'wpml_language', true );
if ( ! $lang ) {
return $value;
}
return apply_filters(
'wpml_translate_single_string',
$value,
'admin_texts_woocommerce_awcdp_deposit_paid_settings',
'[woocommerce_awcdp_deposit_paid_settings]' . $key,
$lang
);
}, 20, 4 );