Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Jeff2Ma/95f433269637f5421f12 to your computer and use it in GitHub Desktop.
Save Jeff2Ma/95f433269637f5421f12 to your computer and use it in GitHub Desktop.
woocommerce-custom-override-checkout-fields
<?php
//以下用部分代码演示hook ‘woocommerce_checkout_fields’ 这个函数
//参考文章:http://devework.com/woocommerce-custom-override-checkout-fields.html
//删除结算页面上多余的表单元素(fields)
add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );
function custom_override_checkout_fields( $fields ) {
//unset($fields['order']['order_comments']);
unset( $fields['billing']['billing_country'] );
//unset( $fields['billing']['billing_first_name'] );
//unset( $fields['billing']['billing_last_name'] );
unset( $fields['billing']['billing_company'] );
unset( $fields['billing']['billing_address_1'] );
unset( $fields['billing']['billing_address_2'] );
unset( $fields['billing']['billing_city'] );
unset( $fields['billing']['billing_state'] );
unset( $fields['billing']['billing_postcode'] );
//unset($fields['billing']['billing_email']);
unset( $fields['billing']['billing_phone'] );
// 将默认的邮箱输入框重置为最大
$fields['billing']['billing_email']['class'] = array('form-row-wide');
//添加自定义的表单元素
$fields['billing']['billing_domain_one'] = array(
'label' => __('域名授权1', 'woocommerce'),
'placeholder' => _x('区分有无www,不含http://', 'placeholder', 'woocommerce'),
'required' => true,
'class' => array('form-row-wide'),
'clear' => true
);
$fields['billing']['billing_domain_two'] = array(
'label' => __('域名授权2', 'woocommerce'),
'placeholder' => _x('区分有无www,不含http://', 'placeholder', 'woocommerce'),
'required' => true,
'class' => array('form-row-wide'),
'clear' => true
);
return $fields;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment