【发布时间】:2018-09-29 21:07:15
【问题描述】:
我正在为我的 Woo 商务结账页面收集额外的用户元数据。
woocommerce_form_field('myName', array(
'type' =>'text',
'class'=>array('my-field-class form-row-wide'),
'label'=>__('First Name'),
'placeholder'=>__('Please enter your name'),
), $checkout->get_value('myName'));
我正在使用以下代码更新数据库:
/*Update the info with the checkout*/
add_action('woocommerce_checkout_field_update_order_meta','my_custom_checkout_field_update_meta');
function my_custom_checkout_field_update_meta($order_id){
if($_POST['MyName'])
update_post_meta($order_id, 'First Name',esc_attr($POST['MyName']));
}
每次提交时,我都会收到内部服务器错误,即使我在本地计算机上工作。我需要收集这些数据并将其保存到订单数据库中。有人帮忙吗?
【问题讨论】:
-
esc_attr($POST['MyName'])不是数组。我想应该是esc_attr($_POST['MyName'])还要检查apacheerror_logs一定有语法错误。 500 internal server Error 简单来说就是脚本错误。 -
是的,你是对的,服务器错误消失了,但我没有在我的订单详细信息中获得附加字段。我错过了什么吗?
-
你想要这个字段在哪里?
标签: php wordpress woocommerce checkout custom-fields