您必须创建自定义AJAX调用来获取和填充这些值。。。
自定义wc订单元。js公司
/*global woocommerce_admin_meta_boxes, woocommerce_admin, accounting, woocommerce_admin_meta_boxes_order */
jQuery( function ( $ ) {
var custom_wc_meta_boxes_order = {
init: function() {
$( \'a.load_customer_billing\' ).on( \'click\', this.load_billing );
$( \'#customer_user\' ).on( \'change\', this.change_customer_user );
},
change_customer_user: function() {
custom_wc_meta_boxes_order.load_billing( true );
},
load_billing: function( force ) {
if ( true === force || window.confirm( woocommerce_admin_meta_boxes.load_billing ) ) {
// Get user ID to load data for
var user_id = $( \'#customer_user\' ).val();
if ( ! user_id ) {
window.alert( woocommerce_admin_meta_boxes.no_customer_selected );
return false;
}
var data = {
user_id: user_id,
type_to_load: \'billing\',
action: \'custom_woocommerce_get_customer_details\',
security: woocommerce_admin_meta_boxes.get_customer_details_nonce
};
$( this ).closest( \'div.edit_address\' ).block({
message: null,
overlayCSS: {
background: \'#fff\',
opacity: 0.6
}
});
$.ajax({
url: woocommerce_admin_meta_boxes.ajax_url,
data: data,
type: \'POST\',
success: function( response ) {
var info = response;
if ( info ) {
$( \'input#_billing_alpha\' ).val( info.billing_alpha ).change();
$( \'input#_billing_beta\' ).val( info.billing_beta ).change();
}
$( \'div.edit_address\' ).unblock();
}
});
}
return false;
},
};
custom_wc_meta_boxes_order.init();
});
自定义woocommerce管理。php
//admin enqueue scripts handler
add_action( \'admin_enqueue_scripts\', \'custom_woocommerce_admin_scripts\', 20 );
function custom_woocommerce_admin_scripts() {
wp_enqueue_script( \'custom_woocommerce_admin\', \'/path/to/custom-wc-order-meta.js\', array( \'wc-admin-meta-boxes\' ), \'0.0.1\' );
}
// add WP admin AJAX handler
add_action( \'wp_ajax_custom_woocommerce_get_customer_details\' , \'custom_woocommerce_get_customer_details\' );
/**
* Get customer details via ajax
*/
function custom_woocommerce_get_customer_details() {
ob_start();
check_ajax_referer( \'get-customer-details\', \'security\' );
if ( ! current_user_can( \'edit_shop_orders\' ) ) {
die(-1);
}
$user_id = (int) trim(stripslashes($_POST[\'user_id\']));
$type_to_load = esc_attr(trim(stripslashes($_POST[\'type_to_load\'])));
$customer_data = array(
$type_to_load . \'_alpha\' => get_user_meta( $user_id, $type_to_load . \'_alpha\', true ),
$type_to_load . \'_beta\' => get_user_meta( $user_id, $type_to_load . \'_beta\', true ),
);
$customer_data = apply_filters( \'custom_woocommerce_found_customer_details\', $customer_data, $user_id, $type_to_load );
wp_send_json( $customer_data );
}