Overview of the Issue
When using Deposits & Partial Payments for WooCommerce with WPML, you might experience the following issues: a translated product does not get the product’s own deposit settings, and the “deposit payment received” email reaches the customer in the default language.
Workaround
Go to WPMLSettings and add the following to the Custom XML Configuration:
<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>Then translate the email texts in WPMLString Translation, and add the following code to the functions.php file of your child theme, so the email text and the payment text use the order language:
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 );