我想添加一个自定义字段,以结帐形式的Woocommerce。该字段显示了我想要的内容,但是name和id属性是错误的。下面是我创建字段的函数。
// Hook in
add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );
// Our hooked in function - $fields is passed via the filter!
function custom_override_checkout_fields( $fields ) {
$fields['billing']['billing_infos'] = array(
'type' => 'textarea',
'label' => __('Notes de la commande', 'woocommerce'),
'placeholder' => _x('Commentaires concernant votre commande', 'placeholder', 'woocommerce'),
'required' => false,
'class' => array('form-row-wide'),
'clear' => true
);
return $fields;
}下面是我在表单中调用它的方式:
<?php woocommerce_form_field( $checkout->checkout_fields['billing'], $checkout->checkout_fields['billing']['billing_infos'], $checkout->get_value( 'billing_infos' ) ); ?>当我检查我的字段时,我得到的是:
<p class="form-row form-row-wide woocommerce-validated" id="Array_field"><label for="Array" class="">Notes de la commande</label><textarea name="Array" class="input-text " id="Array" placeholder="Commentaires concernant votre commande" rows="2" cols="5"></textarea>
</p>发布于 2014-04-15 02:17:25
我解决了我的问题。我调用的函数的第一个参数是错误的。
下面是我应该怎么称呼它:
<?php woocommerce_form_field( 'billing_infos', $checkout->checkout_fields['billing']['billing_infos'], $checkout->get_value( 'billing_infos' ) ); ?>发布于 2016-03-04 18:14:16
https://stackoverflow.com/questions/23001468
复制相似问题