【发布时间】:2021-05-17 17:56:33
【问题描述】:
更新 WooCommerce 和 WordPress 后,许多自定义设置被覆盖,因此我尝试恢复与旧版本相同的功能。 (使用childtheme所以为什么它首先丢失了我不明白) 修复了除此之外的所有内容。在结帐时的帐单信息中,缺少几个字段,默认的 company_name 我又开始工作了,由于某种原因,它在主题 functions.php 中被停用。但是,为 IVA 编号和组织编号留下了两个自定义字段。
所以我使用 Checkout Manager for WooCommerce 将自定义字段添加到账单信息中。 它适用于结帐页面,信息最终出现在订单上。但它不会出现在感谢页面上,更重要的是它不会出现在给客户的电子邮件中。
尝试将其添加到主题 functions.php 但没有运气。
add_filter( 'woocommerce_email_order_meta_fields', 'custom_woocommerce_email_order_meta_fields', 10, 3 );
function custom_woocommerce_email_order_meta_fields( $fields, $sent_to_admin, $order ) {
$fields['billing_wooccm13'] = array(
'label' => __( 'Moms/IVA' ),
'value' => get_post_meta( $order->id, 'billing_wooccm13', true ),
);
return $fields;
}
也试过这个:
add_action('woocommerce_email_customer_details','add_custom_checkout_field_to_emails_notifications', 25, 4 );
function add_custom_checkout_field_to_emails_notifications( $order, $sent_to_admin, $plain_text, $email ) {
$output = '';
$billing_field_testing = get_post_meta( $order->id, 'billing_wooccm13', true );
if ( !empty($billing_wooccm13) )
$output .= '<div><strong>' . __( "Some text:", "woocommerce" ) . '</strong> <span class="text">' . $billing_wooccm13 . '</span></div>';
echo $output;
}
有什么想法可以解决这个问题吗?
【问题讨论】:
标签: php wordpress woocommerce custom-fields orders