【发布时间】:2019-10-19 13:12:52
【问题描述】:
我正在尝试将自定义字段添加到我的 WooCommerce 结帐方案中(尽管这可能是任何地方都有自定义字段的情况)。我想添加两个,但我尝试运行一个函数的每次尝试,它只添加第一个自定义字段而不是第二个。在我的代码中哪里需要清理?
function dv_add_checkout_fields( $fields ) {
$fields['billing_age'] = array(
'label' => __( 'Age of the kid(s) you mainly do activities with?' ),
'type' => 'select',
'class' => array( 'form-row-wide' ),
'priority' => 150,
'required' => true,
'options' => array( '0-2', '3-5', '6-8', '9-12' ),
);
array(
'label' => __( 'Which part of LA do you live in or are closest to?' ),
'type' => 'select',
'class' => array( 'form-row-wide' ),
'priority' => 150,
'required' => true,
'options' => array( 'Central LA', 'East LA', 'San Fernando Valley', 'San Gabriel Valley', 'South Bay', 'West LA', 'Orange County' ),
);
return $fields;
}
add_filter( 'woocommerce_billing_fields', 'dv_add_checkout_fields' );
【问题讨论】:
标签: php wordpress function woocommerce custom-fields