将产品自定义字段添加到WooCommerce已完成的订单电子邮件中

问题描述

有什么方法可以添加我创建的一些产品自定义字段,以包括在WooCommerce已完成订单电子邮件中。

我创建了以下自定义字段:

Product custom field

我已经在主题的functions.php文件中添加了一些代码,以显示以下自定义字段值:

add_action( 'woocommerce_email_after_order_table','add_content_on_specific_email',20,4 );
  
function add_content_on_specific_email( $order,$sent_to_admin,$plain_text,$email )
{
   if ( $email->id == 'customer_completed_order' ) {
      echo '<h3>Informasi Pengambilan Barang</h3><p class="email-upsell-p">Terima Kasih telah mengkonfirmasi pembayaran Anda,Silahkan tunjukan email ini pada saat pengambilan barang dan berikut informasi dan alamat pengambilan barang:</p>';
      echo '<ul><li>Alamat Pengambilan:</strong> ' . get_post_meta( $product_id,'kontak_pemberi',true) . '</li>
      <li>No. Telepon :</strong> ' . get_post_meta( $product_id,'no_hp_pemberi',true) . '</li>
      <li>Nama Pemberi Barang :</strong> ' . get_post_meta( $product_id,'nama_pemberi',true) . '</li>
      </ul>';
   }
}

但是我从来没有得到那些自定义字段值。我在做什么错了?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)