【发布时间】:2017-07-09 13:18:23
【问题描述】:
我获得此代码以将自定义字段添加到 WooCommerce 计费表单。
显示了该字段,但问题是该字段没有 label 也没有 placeholder 也没有 class name。
我在这里缺少什么? 我将此代码添加到我的子主题中的functions.php。
/*******************************
CUSTOM BILLING FIELD
******************************** */
add_filter('woocommerce_billing_fields', 'custom_woocommerce_billing_fields');
function custom_woocommerce_billing_fields($fields)
{
$fields['billing']['billing_options'] = array(
'label' => __('NIF', 'woocommerce'), // Add custom field label
'placeholder' => _x('Your NIF here....', 'placeholder', 'woocommerce'), // Add custom field placeholder
'required' => false, // if field is required or not
'clear' => false, // add clear or not
'type' => 'text', // add field type
'class' => array('my-css') // add class name
);
return $fields;
}
【问题讨论】:
-
您可以将自定义计费字段的代码添加到
get_default_address_fields()文件中的class-wc-countries.php函数
标签: php wordpress woocommerce checkout hook-woocommerce