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, 'class' => 'js_field-country select short', 'type' => 'select', 'options' => array( '' => __( 'Select a country…', 'woocommerce' ) ) + WC()->countries->get_allowed_countries() ), 'state' => array( 'label' => __( 'State/County', 'woocommerce' ), 'class' => 'js_field-state select short', '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', 'class' => 'js_field-country select short', 'options' => array( '' => __( 'Select a country…', 'woocommerce' ) ) + WC()->countries->get_shipping_countries() ), 'state' => array( 'label' => __( 'State/County', 'woocommerce' ), 'class' => 'js_field-state select short', 'show' => false ), ) ); } /** * Output the metabox. * * @param WP_Post $post */ 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(); } else { $payment_gateways = array(); } $payment_method = ! empty( $order->payment_method ) ? $order->payment_method : ''; $order_type_object = get_post_type_object( $post->post_type ); wp_nonce_field( 'woocommerce_save_data', 'woocommerce_meta_nonce' ); ?>

labels->singular_name, $order->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 ); } ?>

@:

customer_user ) ) { $user_id = absint( $order->customer_user ); $user = get_user_by( 'id', $user_id ); $user_string = esc_html( $user->display_name ) . ' (#' . absint( $user->ID ) . ' – ' . esc_html( $user->user_email ) . ')'; } ?>

'; 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'; } if ( ! isset( $field['id'] ) ){ $field['id'] = '_billing_' . $key; } switch ( $field['type'] ) { case 'select' : woocommerce_wp_select( $field ); break; default : woocommerce_wp_text_input( $field ); break; } } ?>

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

'; 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 ( ! empty( 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 Provided Note', 'woocommerce' ) . ': ' . nl2br( esc_html( $post->post_excerpt ) ) . '

'; } echo '
'; // Display form echo '
'; if ( ! empty( self::$shipping_fields ) ) { foreach ( self::$shipping_fields as $key => $field ) { if ( ! isset( $field['type'] ) ) { $field['type'] = 'text'; } if ( ! isset( $field['id'] ) ){ $field['id'] = '_shipping_' . $key; } switch ( $field['type'] ) { case 'select' : woocommerce_wp_select( $field ); break; default : woocommerce_wp_text_input( $field ); 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 ) { if ( ! isset( $field['id'] ) ){ $field['id'] = '_billing_' . $key; } update_post_meta( $post_id, $field['id'], wc_clean( $_POST[ $field['id'] ] ) ); } } if ( ! empty( self::$shipping_fields ) ) { foreach ( self::$shipping_fields as $key => $field ) { if ( ! isset( $field['id'] ) ){ $field['id'] = '_shipping_' . $key; } update_post_meta( $post_id, $field['id'], wc_clean( $_POST[ $field['id'] ] ) ); } } 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'], '', true ); wc_delete_shop_order_transients( $post_id ); } }