【发布时间】:2018-05-09 15:35:52
【问题描述】:
我可以将一组自定义字段添加到我的 WooCommerce 结帐屏幕,但需要将其移动到“帐单详细信息”上方。
如何做到这一点?
根据this official WooCommerce documentation,这是一个添加额外自定义结帐字段的示例代码:
/**
* Add the field to the checkout
*/
add_action( 'woocommerce_after_order_notes', 'my_custom_checkout_field' );
function my_custom_checkout_field( $checkout ) {
echo '<div id="my_custom_checkout_field"><h2>' . __('My Field') . '</h2>';
woocommerce_form_field( 'my_field_name', array(
'type' => 'text',
'class' => array('my-field-class form-row-wide'),
'label' => __('Fill in this field'),
'placeholder' => __('Enter something'),
), $checkout->get_value( 'my_field_name' ));
echo '</div>';
}
【问题讨论】:
标签: php wordpress woocommerce checkout hook-woocommerce