public function select_customer_id() { if (isset($_GET['post_type']) && $_GET['post_type'] == 'shop_order' && isset($_GET['c_id']) && !empty($_GET['c_id'])) { $c_id = $_GET['c_id']; $the_customer = new WC_CRM_Customer($c_id); ob_start(); if ($the_customer->user_id > 0) { $c_name = $the_customer->first_name . ' ' . $the_customer->last_name . ' (#' . $the_customer->user_id . ' - ' . $the_customer->user_email . ')'; ?> jQuery("#customer_user").select2("data", {"id":"<?php echo $the_customer->user_id; ?> ","text":"<?php echo $c_name; ?> "}); <?php } $the_customer->init_address_fields(); $formatted_shipping_address = wp_kses($the_customer->get_formatted_shipping_address(), array("br" => array())); $formatted_billing_address = wp_kses($the_customer->get_formatted_billing_address(), array("br" => array())); $__b_address = $the_customer->billing_fields; $__s_address = $the_customer->shipping_fields; foreach ($__b_address as $key => $field) { $var_name = 'billing_' . $key; ?> jQuery('#_billing_<?php echo $key; ?> ').val( "<?php echo addslashes($the_customer->{$var_name}); ?> " ); <?php } foreach ($__s_address as $key => $field) { $var_name = 'shipping_' . $key; ?> jQuery('#_shipping_<?php echo $key; ?> ').val( "<?php echo addslashes($the_customer->{$var_name}); ?> " ); <?php } ?> jQuery('.order_data_column_container .order_data_column').last().find('.address') .html("<?php echo "<p><strong>" . __("Address", "woocommerce") . ":</strong>" . addslashes($formatted_shipping_address) . "</p>"; ?> "); jQuery('.order_data_column_container .order_data_column').first().next().find('.address') .html("<?php echo "<p><strong>" . __("Address", "woocommerce") . ":</strong>" . addslashes($formatted_billing_address) . "</p>"; ?> "); jQuery('.js_field-country').trigger('change'); <?php $js_string = ob_get_contents(); ob_end_clean(); wc_enqueue_js($js_string); } }