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 = wc_get_order( $post->ID ); } $order = $theorder; self::init_address_fields(); if ( WC()->payment_gateways() ) { $payment_gateways = WC()->payment_gateways->payment_gateways(); } $payment_method = ! empty( $order->payment_method ) ? $order->payment_method : ''; wp_nonce_field( 'woocommerce_save_data', 'woocommerce_meta_nonce' ); ?>

get_order_number() ) ); ?>

get_title() ) : esc_html( $payment_method ) ) ); if ( $transaction_id = $order->get_transaction_id() ) { if ( isset( $payment_gateways[ $payment_method ] ) && ( $url = $payment_gateways[ $payment_method ]->get_transaction_url( $order ) ) ) { echo ' (' . esc_html( $transaction_id ) . ')'; } else { echo ' (' . esc_html( $transaction_id ) . ')'; } } echo '. '; } if ( $ip_address = get_post_meta( $post->ID, '_customer_ip_address', true ) ) { echo __( 'Customer IP', 'woocommerce' ) . ': ' . esc_html( $ip_address ); } ?>

@:

<?php _e( 'Edit', 'woocommerce' ); ?>

'; 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'] ) && false === $field['show'] ) { continue; } $field_name = 'billing_' . $key; if ( $order->$field_name ) { echo '

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

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

'; foreach ( self::$billing_fields as $key => $field ) { if ( ! isset( $field['type'] ) ) { $field['type'] = 'text'; } switch ( $field['type'] ) { case 'select' : // allow for setting a default value programaticaly, and draw the selectbox woocommerce_wp_select( array( 'id' => '_billing_' . $key, 'label' => $field['label'], 'options' => $field['options'], 'value' => isset( $field['value'] ) ? $field['value'] : '' ) ); break; default : // allow for setting a default value programaticaly, and draw the textbox woocommerce_wp_text_input( array( 'id' => '_billing_' . $key, 'label' => $field['label'], 'value' => isset( $field['value'] ) ? $field['value'] : '' ) ); break; } } ?>

'_transaction_id', 'label' => __( 'Transaction ID', 'woocommerce' ) ) ); echo '
'; do_action( 'woocommerce_admin_order_data_after_billing_address', $order ); ?>

<?php _e( 'Edit', 'woocommerce' ); ?>

'; 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'] ) && false === $field['show'] ) { 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', 'yes' == get_option( 'woocommerce_enable_order_comments', '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', 'yes' == get_option( 'woocommerce_enable_order_comments', '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 ] ) ); } } if ( isset( $_POST['_transaction_id'] ) ) { update_post_meta( $post_id, '_transaction_id', wc_clean( $_POST[ '_transaction_id' ] ) ); } // 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 = wc_get_order( $post_id ); // Order status $order->update_status( $_POST['order_status'] ); wc_delete_shop_order_transients( $post_id ); } }