以管理员顺序显示Woocommerce自定义结帐字段值,使其可编辑 [英] Show Woocommerce custom checkout field value in admin order making them editable
问题描述
我正在使用"回答我的一个问题,以显示/隐藏自定义的结帐计费字段,效果很好.
I am using "Show hide custom WooCommerce checkout field based on selected payment method" answer to one of my questions, to show / hide a custom checkout billing field, and it works fine.
问题:是否可以在管理面板的WooCommerce订单中显示我的自定义"字段?
Question: Is it possible to show my Custom field in WooCommerce orders in the admin panel?
推荐答案
要在帐单信息"列上的管理订单页面中显示"billing_options"自定义结帐帐单字段值,请使用以下命令:
To display "billing_options" custom checkout billing field value in admin order pages on the billing information column, use the following:
add_action( 'woocommerce_admin_order_data_after_billing_address', 'display_billing_options_value_in_admin_order', 10, 1 );
function display_billing_options_value_in_admin_order($order){
if( $value = get_post_meta( $order->get_id(), '_billing_options', true ) )
echo '<p><strong>'.__('Invoice Number', 'woocommerce').':</strong> ' . $value . '</p>';
}
要使此自定义结帐单字段在后端显示为可编辑,请使用以下命令:
To make this custom checkout billing field appear as editable in backend use the following:
add_filter( 'woocommerce_admin_billing_fields', 'custom_admin_billing_fields', 10, 1 );
function custom_admin_billing_fields( $fields ) {
$fields['options'] = array(
'label' => __('Invoice Number', 'woocommerce'),
'show' => true,
);
return $fields;
}
代码进入您的活动子主题(或活动主题)的function.php文件中.经过测试并可以正常工作.
Code goes in function.php file of your active child theme (or active theme). tested and works.
这篇关于以管理员顺序显示Woocommerce自定义结帐字段值,使其可编辑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!