ภาพรวมของปัญหา
เมื่อใช้ Deposits & Partial Payments for WooCommerce ร่วมกับ WPML คุณอาจพบปัญหาต่อไปนี้: สินค้าที่แปลแล้วไม่ได้รับการตั้งค่าการมัดจำของสินค้านั้น และอีเมล “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 );