문제 개요
WPML과 함께 Deposits & Partial Payments for WooCommerce를 사용할 때 다음과 같은 문제가 발생할 수 있습니다. 번역된 제품에 제품 자체의 보증금 설정이 적용되지 않으며, “deposit payment received” 이메일이 고객에게 기본 언어로 전송됩니다.
임시 해결 방법
WPML설정으로 이동하여 사용자 정의 XML 구성에 다음을 추가하세요.
<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>그런 다음 WPML문자열 번역에서 이메일 텍스트를 번역하고, 하위 테마의 functions.php 파일에 다음 코드를 추가하여 이메일 텍스트와 결제 텍스트가 주문 언어를 사용하도록 하세요.
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 );