array( 'label' => __( 'First Name', 'woocommerce' ), 'show' => false ), 'last_name' => array( 'label' => __( 'Last Name', 'woocommerce' ), 'show' => false ), 'company' => array( 'label' => __( 'Company', 'woocommerce' ), 'show' => false ), 'address_1' => array( 'label' => __( 'Address 1', 'woocommerce' ), 'show' => false ), 'address_2' => array( 'label' => __( 'Address 2', 'woocommerce' ), 'show' => false ), 'city' => array( 'label' => __( 'City', 'woocommerce' ), 'show' => false ), 'postcode' => array( 'label' => __( 'Postcode', 'woocommerce' ), 'show' => false ), 'country' => array( 'label' => __( 'Country', 'woocommerce' ), 'show' => false, 'type' => 'select', 'options' => array( '' => __( 'Select a country…', 'woocommerce' ) ) + WC()->countries->get_allowed_countries() ), 'state' => array( 'label' => __( 'State/County', 'woocommerce' ), 'show' => false ), 'email' => array( 'label' => __( 'Email', 'woocommerce' ), ), 'phone' => array( 'label' => __( 'Phone', 'woocommerce' ), ), ) ); self::$shipping_fields = apply_filters( 'woocommerce_admin_shipping_fields', array( 'first_name' => array( 'label' => __( 'First Name', 'woocommerce' ), 'show' => false ), 'last_name' => array( 'label' => __( 'Last Name', 'woocommerce' ), 'show' => false ), 'company' => array( 'label' => __( 'Company', 'woocommerce' ), 'show' => false ), 'address_1' => array( 'label' => __( 'Address 1', 'woocommerce' ), 'show' => false ), 'address_2' => array( 'label' => __( 'Address 2', 'woocommerce' ), 'show' => false ), 'city' => array( 'label' => __( 'City', 'woocommerce' ), 'show' => false ), 'postcode' => array( 'label' => __( 'Postcode', 'woocommerce' ), 'show' => false ), 'country' => array( 'label' => __( 'Country', 'woocommerce' ), 'show' => false, 'type' => 'select', 'options' => array( '' => __( 'Select a country…', 'woocommerce' ) ) + WC()->countries->get_shipping_countries() ), 'state' => array( 'label' => __( 'State/County', 'woocommerce' ), 'show' => false ), ) ); } /** * Output the metabox */ public static function output( $post ) { global $theorder; if ( ! is_object( $theorder ) ) $theorder = new WC_Order( $post->ID ); $order = $theorder; self::init_address_fields(); wp_nonce_field( 'woocommerce_save_data', 'woocommerce_meta_nonce' ); ?>

get_order_number() ) . '. '; if ( $ip_address = get_post_meta( $post->ID, '_customer_ip_address', true ) ) echo __( 'Customer IP:', 'woocommerce' ) . ' ' . esc_html( $ip_address ); ?>

@:

Edit

'; if ( $order->get_formatted_billing_address() ) echo '

' . __( 'Address', 'woocommerce' ) . ':' . wp_kses( $order->get_formatted_billing_address(), array( 'br' => array() ) ) . '

'; else echo '

' . __( 'Address', 'woocommerce' ) . ': ' . __( 'No billing address set.', 'woocommerce' ) . '

'; foreach ( self::$billing_fields as $key => $field ) { if ( isset( $field['show'] ) && $field['show'] === false ) continue; $field_name = 'billing_' . $key; if ( $order->$field_name ) echo '

' . esc_html( $field['label'] ) . ': ' . make_clickable( esc_html( $order->$field_name ) ) . '

'; } if ( WC()->payment_gateways() ) $payment_gateways = WC()->payment_gateways->payment_gateways(); $payment_method = ! empty( $order->payment_method ) ? $order->payment_method : ''; if ( $payment_method ) echo '

' . __( 'Payment Method', 'woocommerce' ) . ': ' . ( isset( $payment_gateways[ $payment_method ] ) ? esc_html( $payment_gateways[ $payment_method ]->get_title() ) : esc_html( $payment_method ) ) . '

'; echo '
'; // Display form echo '

'; foreach ( self::$billing_fields as $key => $field ) { if ( ! isset( $field['type'] ) ) $field['type'] = 'text'; switch ( $field['type'] ) { case "select" : woocommerce_wp_select( array( 'id' => '_billing_' . $key, 'label' => $field['label'], 'options' => $field['options'] ) ); break; default : woocommerce_wp_text_input( array( 'id' => '_billing_' . $key, 'label' => $field['label'] ) ); break; } } ?>

'; do_action( 'woocommerce_admin_order_data_after_billing_address', $order ); ?>

Edit

'; if ( $order->get_formatted_shipping_address() ) echo '

' . __( 'Address', 'woocommerce' ) . ':' . wp_kses( $order->get_formatted_shipping_address(), array( 'br' => array() ) ) . '

'; else echo '

' . __( 'Address', 'woocommerce' ) . ': ' . __( 'No shipping address set.', 'woocommerce' ) . '

'; if ( self::$shipping_fields ) foreach ( self::$shipping_fields as $key => $field ) { if ( isset( $field['show'] ) && $field['show'] === false ) continue; $field_name = 'shipping_' . $key; if ( ! empty( $order->$field_name ) ) echo '

' . esc_html( $field['label'] ) . ': ' . make_clickable( esc_html( $order->$field_name ) ) . '

'; } if ( apply_filters( 'woocommerce_enable_order_notes_field', get_option( 'woocommerce_enable_order_comments', 'yes' ) == 'yes' ) && $post->post_excerpt ) echo '

' . __( 'Customer Note', 'woocommerce' ) . ': ' . nl2br( esc_html( $post->post_excerpt ) ) . '

'; echo '
'; // Display form echo '

'; if ( self::$shipping_fields ) foreach ( self::$shipping_fields as $key => $field ) { if ( ! isset( $field['type'] ) ) $field['type'] = 'text'; switch ( $field['type'] ) { case "select" : woocommerce_wp_select( array( 'id' => '_shipping_' . $key, 'label' => $field['label'], 'options' => $field['options'] ) ); break; default : woocommerce_wp_text_input( array( 'id' => '_shipping_' . $key, 'label' => $field['label'] ) ); break; } } if ( apply_filters( 'woocommerce_enable_order_notes_field', get_option( 'woocommerce_enable_order_comments', 'yes' ) == 'yes' ) ) { ?>

'; do_action( 'woocommerce_admin_order_data_after_shipping_address', $order ); ?>
$field ) update_post_meta( $post_id, '_billing_' . $key, wc_clean( $_POST[ '_billing_' . $key ] ) ); if ( self::$shipping_fields ) foreach ( self::$shipping_fields as $key => $field ) update_post_meta( $post_id, '_shipping_' . $key, wc_clean( $_POST[ '_shipping_' . $key ] ) ); // Payment method handling if ( get_post_meta( $post_id, '_payment_method', true ) !== stripslashes( $_POST['_payment_method'] ) ) { $methods = WC()->payment_gateways->payment_gateways(); $payment_method = wc_clean( $_POST['_payment_method'] ); $payment_method_title = $payment_method; if ( isset( $methods) && isset( $methods[ $payment_method ] ) ) $payment_method_title = $methods[ $payment_method ]->get_title(); update_post_meta( $post_id, '_payment_method', $payment_method ); update_post_meta( $post_id, '_payment_method_title', $payment_method_title ); } // Update date if ( empty( $_POST['order_date'] ) ) { $date = current_time('timestamp'); } else { $date = strtotime( $_POST['order_date'] . ' ' . (int) $_POST['order_date_hour'] . ':' . (int) $_POST['order_date_minute'] . ':00' ); } $date = date_i18n( 'Y-m-d H:i:s', $date ); $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->posts SET post_date = %s, post_date_gmt = %s WHERE ID = %s", $date, get_gmt_from_date( $date ), $post_id ) ); // Order data saved, now get it so we can manipulate status $order = new WC_Order( $post_id ); // Order status $order->update_status( $_POST['order_status'] ); wc_delete_shop_order_transients( $post_id ); } }