php 重新排序WooCommerce中的结帐字段

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php 重新排序WooCommerce中的结帐字段相关的知识,希望对你有一定的参考价值。

// Reorder Checkout Fields
add_filter('woocommerce_checkout_fields','reorder_woo_fields');
 
function reorder_woo_fields($fields) {
	$fields2['billing']['billing_email'] = $fields['billing']['billing_email'];
    $fields2['billing']['billing_first_name'] = $fields['billing']['billing_first_name'];
    $fields2['billing']['billing_last_name'] = $fields['billing']['billing_last_name'];
    $fields2['billing']['billing_country'] = $fields['billing']['billing_country'];
    $fields2['billing']['billing_address_1'] = $fields['billing']['billing_address_1'];
    $fields2['billing']['billing_address_2'] = $fields['billing']['billing_address_2'];
    $fields2['billing']['billing_city'] = $fields['billing']['billing_city'];
    $fields2['billing']['billing_postcode'] = $fields['billing']['billing_postcode'];
    $fields2['billing']['billing_state'] = $fields['billing']['billing_state'];
	$fields2['billing']['billing_phone'] = $fields['billing']['billing_phone'];

    $fields2['shipping']['shipping_first_name'] = $fields['shipping']['shipping_first_name'];
    $fields2['shipping']['shipping_last_name'] = $fields['shipping']['shipping_last_name'];
    $fields2['shipping']['shipping_country'] = $fields['shipping']['shipping_country'];
    $fields2['shipping']['shipping_address_1'] = $fields['shipping']['shipping_address_1'];
    $fields2['shipping']['shipping_address_2'] = $fields['shipping']['shipping_address_2'];
    $fields2['shipping']['shipping_city'] = $fields['shipping']['shipping_city'];
    $fields2['shipping']['shipping_postcode'] = $fields['shipping']['shipping_postcode'];
    $fields2['shipping']['shipping_state'] = $fields['shipping']['shipping_state'];

 
    // Add full width Classes and Clears to Adjustments
    $fields2['billing']['billing_email'] = array(
		'label'     => __('Email', 'woocommerce'),
	    'required'  => true,
	    'class'     => array('form-row-wide'),
	    'clear'     => true
    );
    $fields2['billing']['billing_phone'] = array(
		'label'     => __('Phone', 'woocommerce'),
	    'required'  => false,
	    'class'     => array('form-row-wide'),
	    'clear'     => true
    );

    return $fields2;
}

以上是关于php 重新排序WooCommerce中的结帐字段的主要内容,如果未能解决你的问题,请参考以下文章

php 重新排序结帐字段#woo

php [使用操作和过滤器自定义结帐字段]保存WooCommerce自定义结帐字段

php [使用操作和过滤器自定义结帐字段]验证WooCommerce自定义结帐字段

php 预先填充WooCommerce结帐字段

php WooCommerce自定义结帐字段

php [使用操作和过滤器自定义结帐字段]向电子邮件添加自定义WooCommerce结帐字段