根据语言将静态 pdf 添加到电子邮件 - WooCommerce

发布于 2025-01-10 22:33:19 字数 591 浏览 0 评论 0 原文

成功签出静态 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;
}

I need to add to the attachment of the confirmation mail after successful checkout static pdf attachment, but changing the source route of the file based on language he chose on my website. I use this code to attach the static pdf to the attachment:

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;
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一萌ing 2025-01-17 22:33:19

使用 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";
}

Use get_locale() for get the website 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";
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文