根据语言将静态 pdf 添加到电子邮件 - WooCommerce
Add static pdf to an email based on language - WooCommerce
我需要在结帐成功后添加到确认邮件的附件静态pdf附件,但根据他在我网站上选择的语言更改文件的源路径。我使用此代码将静态 pdf 附加到附件:
add_filter( 'woocommerce_email_attachments', 'wphelp_email_files_woo', 10, 4 );
function wphelp_email_files_woo( $attachments, $email_id, $order, $email ) {
$email_ids = array( 'new_order', 'customer_processing_order' );
if ( in_array ( $email_id, $email_ids ) ) {
$upload_dir = wp_upload_dir();
$attachments[] = $upload_dir['basedir'] . "/2021/12/FORMULAR_NA_ODSTUPENIE_OD_ZMLUVY-1.pdf"; //Change the route and name for yours
}
return $attachments;
}
使用 get_locale()
获取网站区域设置。
if (get_locale() == 'en_GB'){
$attachments[] = $upload_dir['basedir'] . "/2021/12/FORMULAR_NA_ODSTUPENIE_OD_ZMLUVY-1.pdf";
}
else {
$attachments[] = $upload_dir['basedir'] . "/2021/12/otherfile.pdf";
}
我需要在结帐成功后添加到确认邮件的附件静态pdf附件,但根据他在我网站上选择的语言更改文件的源路径。我使用此代码将静态 pdf 附加到附件:
add_filter( 'woocommerce_email_attachments', 'wphelp_email_files_woo', 10, 4 );
function wphelp_email_files_woo( $attachments, $email_id, $order, $email ) {
$email_ids = array( 'new_order', 'customer_processing_order' );
if ( in_array ( $email_id, $email_ids ) ) {
$upload_dir = wp_upload_dir();
$attachments[] = $upload_dir['basedir'] . "/2021/12/FORMULAR_NA_ODSTUPENIE_OD_ZMLUVY-1.pdf"; //Change the route and name for yours
}
return $attachments;
}
使用 get_locale()
获取网站区域设置。
if (get_locale() == 'en_GB'){
$attachments[] = $upload_dir['basedir'] . "/2021/12/FORMULAR_NA_ODSTUPENIE_OD_ZMLUVY-1.pdf";
}
else {
$attachments[] = $upload_dir['basedir'] . "/2021/12/otherfile.pdf";
}