2013-08-06 10:41:20 +00:00
< ? php
/**
* Order Data
*
* Functions for displaying the order data meta box .
*
* @ author WooThemes
* @ category Admin
* @ package WooCommerce / Admin / Meta Boxes
2014-06-11 19:50:15 +00:00
* @ version 2.2 . 0
2013-08-06 10:41:20 +00:00
*/
2014-06-11 19:50:15 +00:00
if ( ! defined ( 'ABSPATH' ) ) {
exit ; // Exit if accessed directly
}
2013-08-06 10:41:20 +00:00
/**
2014-09-20 20:05:06 +00:00
* WC_Meta_Box_Order_Data Class
2013-08-06 10:41:20 +00:00
*/
class WC_Meta_Box_Order_Data {
2014-06-11 19:50:15 +00:00
/**
* Billing fields
*
* @ var array
*/
private static $billing_fields = array ();
/**
* Shipping fields
*
* @ var array
*/
private static $shipping_fields = array ();
2013-08-06 10:41:20 +00:00
/**
* Init billing and shipping fields we display + save
*/
public static function init_address_fields () {
2014-08-31 07:18:21 +00:00
2013-08-06 10:41:20 +00:00
self :: $billing_fields = apply_filters ( 'woocommerce_admin_billing_fields' , array (
'first_name' => array (
'label' => __ ( 'First Name' , 'woocommerce' ),
2014-06-11 19:50:15 +00:00
'show' => false
),
2013-08-06 10:41:20 +00:00
'last_name' => array (
'label' => __ ( 'Last Name' , 'woocommerce' ),
2014-06-11 19:50:15 +00:00
'show' => false
),
2013-08-06 10:41:20 +00:00
'company' => array (
'label' => __ ( 'Company' , 'woocommerce' ),
2014-06-11 19:50:15 +00:00
'show' => false
),
2013-08-06 10:41:20 +00:00
'address_1' => array (
'label' => __ ( 'Address 1' , 'woocommerce' ),
2014-06-11 19:50:15 +00:00
'show' => false
),
2013-08-06 10:41:20 +00:00
'address_2' => array (
'label' => __ ( 'Address 2' , 'woocommerce' ),
2014-06-11 19:50:15 +00:00
'show' => false
),
2013-08-06 10:41:20 +00:00
'city' => array (
'label' => __ ( 'City' , 'woocommerce' ),
2014-06-11 19:50:15 +00:00
'show' => false
),
2013-08-06 10:41:20 +00:00
'postcode' => array (
'label' => __ ( 'Postcode' , 'woocommerce' ),
2014-06-11 19:50:15 +00:00
'show' => false
),
2013-08-06 10:41:20 +00:00
'country' => array (
2014-06-11 19:50:15 +00:00
'label' => __ ( 'Country' , 'woocommerce' ),
'show' => false ,
'type' => 'select' ,
2013-08-06 10:41:20 +00:00
'options' => array ( '' => __ ( 'Select a country…' , 'woocommerce' ) ) + WC () -> countries -> get_allowed_countries ()
2014-06-11 19:50:15 +00:00
),
2013-08-06 10:41:20 +00:00
'state' => array (
'label' => __ ( 'State/County' , 'woocommerce' ),
2014-06-11 19:50:15 +00:00
'show' => false
),
2013-08-06 10:41:20 +00:00
'email' => array (
'label' => __ ( 'Email' , 'woocommerce' ),
2014-06-11 19:50:15 +00:00
),
2013-08-06 10:41:20 +00:00
'phone' => array (
'label' => __ ( 'Phone' , 'woocommerce' ),
2014-06-11 19:50:15 +00:00
),
2013-08-06 10:41:20 +00:00
) );
self :: $shipping_fields = apply_filters ( 'woocommerce_admin_shipping_fields' , array (
'first_name' => array (
'label' => __ ( 'First Name' , 'woocommerce' ),
2014-06-11 19:50:15 +00:00
'show' => false
),
2013-08-06 10:41:20 +00:00
'last_name' => array (
'label' => __ ( 'Last Name' , 'woocommerce' ),
2014-06-11 19:50:15 +00:00
'show' => false
),
2013-08-06 10:41:20 +00:00
'company' => array (
'label' => __ ( 'Company' , 'woocommerce' ),
2014-06-11 19:50:15 +00:00
'show' => false
),
2013-08-06 10:41:20 +00:00
'address_1' => array (
'label' => __ ( 'Address 1' , 'woocommerce' ),
2014-06-11 19:50:15 +00:00
'show' => false
),
2013-08-06 10:41:20 +00:00
'address_2' => array (
'label' => __ ( 'Address 2' , 'woocommerce' ),
2014-06-11 19:50:15 +00:00
'show' => false
),
2013-08-06 10:41:20 +00:00
'city' => array (
'label' => __ ( 'City' , 'woocommerce' ),
2014-06-11 19:50:15 +00:00
'show' => false
),
2013-08-06 10:41:20 +00:00
'postcode' => array (
'label' => __ ( 'Postcode' , 'woocommerce' ),
2014-06-11 19:50:15 +00:00
'show' => false
),
2013-08-06 10:41:20 +00:00
'country' => array (
2014-06-11 19:50:15 +00:00
'label' => __ ( 'Country' , 'woocommerce' ),
'show' => false ,
'type' => 'select' ,
2013-08-06 10:41:20 +00:00
'options' => array ( '' => __ ( 'Select a country…' , 'woocommerce' ) ) + WC () -> countries -> get_shipping_countries ()
2014-06-11 19:50:15 +00:00
),
2013-08-06 10:41:20 +00:00
'state' => array (
'label' => __ ( 'State/County' , 'woocommerce' ),
2014-06-11 19:50:15 +00:00
'show' => false
),
2013-08-06 10:41:20 +00:00
) );
}
/**
* Output the metabox
*/
public static function output ( $post ) {
global $theorder ;
2014-06-11 19:50:15 +00:00
if ( ! is_object ( $theorder ) ) {
2014-08-15 12:29:21 +00:00
$theorder = wc_get_order ( $post -> ID );
2014-06-11 19:50:15 +00:00
}
2013-08-06 10:41:20 +00:00
$order = $theorder ;
self :: init_address_fields ();
2014-06-27 12:12:10 +00:00
if ( WC () -> payment_gateways () ) {
$payment_gateways = WC () -> payment_gateways -> payment_gateways ();
}
$payment_method = ! empty ( $order -> payment_method ) ? $order -> payment_method : '' ;
2013-08-06 10:41:20 +00:00
wp_nonce_field ( 'woocommerce_save_data' , 'woocommerce_meta_nonce' );
?>
< style type = " text/css " >
#post-body-content, #titlediv, #major-publishing-actions, #minor-publishing-actions, #visibility, #submitdiv { display:none }
</ style >
< div class = " panel-wrap woocommerce " >
< input name = " post_title " type = " hidden " value = " <?php echo empty( $post->post_title ) ? 'Order' : esc_attr( $post->post_title ); ?> " />
2014-07-10 20:41:53 +00:00
< input name = " post_status " type = " hidden " value = " <?php echo esc_attr( $order->get_status () ); ?> " />
2013-08-06 10:41:20 +00:00
< div id = " order_data " class = " panel " >
2014-06-27 12:12:10 +00:00
< h2 >< ? php printf ( __ ( 'Order %s details' , 'woocommerce' ), esc_html ( $order -> get_order_number () ) ); ?> </h2>
2013-08-06 10:41:20 +00:00
< p class = " order_number " >< ? php
2014-06-27 12:12:10 +00:00
if ( $payment_method ) {
printf ( __ ( 'Payment via %s' , 'woocommerce' ), ( isset ( $payment_gateways [ $payment_method ] ) ? esc_html ( $payment_gateways [ $payment_method ] -> get_title () ) : esc_html ( $payment_method ) ) );
2014-07-07 10:44:35 +00:00
if ( $transaction_id = $order -> get_transaction_id () ) {
2014-08-28 01:51:03 +00:00
if ( isset ( $payment_gateways [ $payment_method ] ) && ( $url = $payment_gateways [ $payment_method ] -> get_transaction_url ( $order ) ) ) {
2014-06-27 12:12:10 +00:00
echo ' (<a href="' . esc_url ( $url ) . '" target="_blank">' . esc_html ( $transaction_id ) . '</a>)' ;
} else {
echo ' (' . esc_html ( $transaction_id ) . ')' ;
}
}
echo '. ' ;
}
2013-08-06 10:41:20 +00:00
2014-06-11 19:50:15 +00:00
if ( $ip_address = get_post_meta ( $post -> ID , '_customer_ip_address' , true ) ) {
2014-06-27 12:12:10 +00:00
echo __ ( 'Customer IP' , 'woocommerce' ) . ': ' . esc_html ( $ip_address );
2014-06-11 19:50:15 +00:00
}
2013-08-06 10:41:20 +00:00
?> </p>
< div class = " order_data_column_container " >
< div class = " order_data_column " >
< h4 >< ? php _e ( 'General Details' , 'woocommerce' ); ?> </h4>
2013-08-16 15:43:26 +00:00
< p class = " form-field form-field-wide " >< label for = " order_date " >< ? php _e ( 'Order date:' , 'woocommerce' ) ?> </label>
< input type = " text " class = " date-picker-field " name = " order_date " id = " order_date " maxlength = " 10 " value = " <?php echo date_i18n( 'Y-m-d', strtotime( $post->post_date ) ); ?> " pattern = " [0-9] { 4}-(0[1-9]|1[012])-(0[1-9]|1[0-9]|2[0-9]|3[01]) " />@< input type = " text " class = " hour " placeholder = " <?php _e( 'h', 'woocommerce' ) ?> " name = " order_date_hour " id = " order_date_hour " maxlength = " 2 " size = " 2 " value = " <?php echo date_i18n( 'H', strtotime( $post->post_date ) ); ?> " pattern = " \ -? \ d+( \ . \ d { 0,})? " />:< input type = " text " class = " minute " placeholder = " <?php _e( 'm', 'woocommerce' ) ?> " name = " order_date_minute " id = " order_date_minute " maxlength = " 2 " size = " 2 " value = " <?php echo date_i18n( 'i', strtotime( $post->post_date ) ); ?> " pattern = " \ -? \ d+( \ . \ d { 0,})? " />
</ p >
< p class = " form-field form-field-wide " >< label for = " order_status " >< ? php _e ( 'Order status:' , 'woocommerce' ) ?> </label>
2013-08-06 10:41:20 +00:00
< select id = " order_status " name = " order_status " class = " chosen_select " >
< ? php
2014-05-30 16:47:00 +00:00
$statuses = wc_get_order_statuses ();
foreach ( $statuses as $status => $status_name ) {
2014-06-03 10:29:01 +00:00
echo '<option value="' . esc_attr ( $status ) . '" ' . selected ( $status , 'wc-' . $order -> get_status (), false ) . '>' . esc_html ( $status_name ) . '</option>' ;
2013-08-06 10:41:20 +00:00
}
?>
</ select ></ p >
< p class = " form-field form-field-wide " >
< label for = " customer_user " >< ? php _e ( 'Customer:' , 'woocommerce' ) ?> </label>
< select id = " customer_user " name = " customer_user " class = " ajax_chosen_select_customer " >
< option value = " " >< ? php _e ( 'Guest' , 'woocommerce' ) ?> </option>
< ? php
if ( $order -> customer_user ) {
$user = get_user_by ( 'id' , $order -> customer_user );
echo '<option value="' . esc_attr ( $user -> ID ) . '" ' . selected ( 1 , 1 , false ) . '>' . esc_html ( $user -> display_name ) . ' (#' . absint ( $user -> ID ) . ' – ' . esc_html ( $user -> user_email ) . ')</option>' ;
}
?>
</ select >
</ p >
< ? php do_action ( 'woocommerce_admin_order_data_after_order_details' , $order ); ?>
</ div >
< div class = " order_data_column " >
2014-06-11 20:12:23 +00:00
< h4 >< ? php _e ( 'Billing Details' , 'woocommerce' ); ?> <a class="edit_address" href="#"><img src="<?php echo WC()->plugin_url(); ?>/assets/images/icons/edit.png" alt="<?php _e( 'Edit', 'woocommerce' ); ?>" width="14" /></a></h4>
2013-08-06 10:41:20 +00:00
< ? php
// Display values
echo '<div class="address">' ;
2014-06-11 19:50:15 +00:00
if ( $order -> get_formatted_billing_address () ) {
2014-02-11 09:56:41 +00:00
echo '<p><strong>' . __ ( 'Address' , 'woocommerce' ) . ':</strong>' . wp_kses ( $order -> get_formatted_billing_address (), array ( 'br' => array () ) ) . '</p>' ;
2014-06-11 19:50:15 +00:00
} else {
2013-08-06 10:41:20 +00:00
echo '<p class="none_set"><strong>' . __ ( 'Address' , 'woocommerce' ) . ':</strong> ' . __ ( 'No billing address set.' , 'woocommerce' ) . '</p>' ;
2014-06-11 19:50:15 +00:00
}
2013-08-06 10:41:20 +00:00
foreach ( self :: $billing_fields as $key => $field ) {
2014-06-11 19:50:15 +00:00
if ( isset ( $field [ 'show' ] ) && false === $field [ 'show' ] ) {
2013-08-06 10:41:20 +00:00
continue ;
2014-06-11 19:50:15 +00:00
}
2013-08-06 10:41:20 +00:00
$field_name = 'billing_' . $key ;
2014-06-11 19:50:15 +00:00
if ( $order -> $field_name ) {
2013-08-16 15:43:26 +00:00
echo '<p><strong>' . esc_html ( $field [ 'label' ] ) . ':</strong> ' . make_clickable ( esc_html ( $order -> $field_name ) ) . '</p>' ;
2014-06-11 19:50:15 +00:00
}
2013-08-06 10:41:20 +00:00
}
echo '</div>' ;
// Display form
2014-06-11 19:50:15 +00:00
echo '<div class="edit_address"><p><button class="button load_customer_billing">' . __ ( 'Load billing address' , 'woocommerce' ) . '</button></p>' ;
2013-08-06 10:41:20 +00:00
foreach ( self :: $billing_fields as $key => $field ) {
2014-06-11 19:50:15 +00:00
if ( ! isset ( $field [ 'type' ] ) ) {
2013-08-06 10:41:20 +00:00
$field [ 'type' ] = 'text' ;
2014-06-11 19:50:15 +00:00
}
2013-08-06 10:41:20 +00:00
switch ( $field [ 'type' ] ) {
2014-06-11 19:50:15 +00:00
case 'select' :
2014-09-18 15:33:49 +00:00
// allow for setting a default value programaticaly, and draw the selectbox
2014-10-08 14:13:26 +00:00
woocommerce_wp_select ( array ( 'id' => '_billing_' . $key , 'label' => $field [ 'label' ], 'options' => $field [ 'options' ], 'value' => isset ( $field [ 'value' ] ) ? $field [ 'value' ] : null ) );
2013-08-06 10:41:20 +00:00
break ;
default :
2014-09-18 15:33:49 +00:00
// allow for setting a default value programaticaly, and draw the textbox
2014-10-08 14:13:26 +00:00
woocommerce_wp_text_input ( array ( 'id' => '_billing_' . $key , 'label' => $field [ 'label' ], 'value' => isset ( $field [ 'value' ] ) ? $field [ 'value' ] : null ) );
2013-08-06 10:41:20 +00:00
break ;
}
}
2013-08-16 15:43:26 +00:00
?>
< p class = " form-field form-field-wide " >
< label >< ? php _e ( 'Payment Method:' , 'woocommerce' ); ?> </label>
< select name = " _payment_method " id = " _payment_method " class = " first " >
< option value = " " >< ? php _e ( 'N/A' , 'woocommerce' ); ?> </option>
< ? php
$found_method = false ;
foreach ( $payment_gateways as $gateway ) {
if ( $gateway -> enabled == " yes " ) {
echo '<option value="' . esc_attr ( $gateway -> id ) . '" ' . selected ( $payment_method , $gateway -> id , false ) . '>' . esc_html ( $gateway -> get_title () ) . '</option>' ;
2014-06-11 19:50:15 +00:00
if ( $payment_method == $gateway -> id ) {
2013-08-16 15:43:26 +00:00
$found_method = true ;
2014-06-11 19:50:15 +00:00
}
2013-08-16 15:43:26 +00:00
}
}
if ( ! $found_method && ! empty ( $payment_method ) ) {
echo '<option value="' . esc_attr ( $payment_method ) . '" selected="selected">' . __ ( 'Other' , 'woocommerce' ) . '</option>' ;
} else {
echo '<option value="other">' . __ ( 'Other' , 'woocommerce' ) . '</option>' ;
}
?>
</ select >
</ p >
< ? php
2014-06-27 12:12:10 +00:00
woocommerce_wp_text_input ( array ( 'id' => '_transaction_id' , 'label' => __ ( 'Transaction ID' , 'woocommerce' ) ) );
2013-08-06 10:41:20 +00:00
echo '</div>' ;
do_action ( 'woocommerce_admin_order_data_after_billing_address' , $order );
?>
</ div >
< div class = " order_data_column " >
2014-06-11 20:12:23 +00:00
< h4 >< ? php _e ( 'Shipping Details' , 'woocommerce' ); ?> <a class="edit_address" href="#"><img src="<?php echo WC()->plugin_url(); ?>/assets/images/icons/edit.png" alt="<?php _e( 'Edit', 'woocommerce' ); ?>" width="14" /></a></h4>
2013-08-06 10:41:20 +00:00
< ? php
// Display values
echo '<div class="address">' ;
2014-06-11 19:50:15 +00:00
if ( $order -> get_formatted_shipping_address () ) {
2014-02-11 09:56:41 +00:00
echo '<p><strong>' . __ ( 'Address' , 'woocommerce' ) . ':</strong>' . wp_kses ( $order -> get_formatted_shipping_address (), array ( 'br' => array () ) ) . '</p>' ;
2014-06-11 19:50:15 +00:00
} else {
2013-08-06 10:41:20 +00:00
echo '<p class="none_set"><strong>' . __ ( 'Address' , 'woocommerce' ) . ':</strong> ' . __ ( 'No shipping address set.' , 'woocommerce' ) . '</p>' ;
2014-06-11 19:50:15 +00:00
}
2013-08-06 10:41:20 +00:00
2014-06-11 19:50:15 +00:00
if ( self :: $shipping_fields ) {
foreach ( self :: $shipping_fields as $key => $field ) {
if ( isset ( $field [ 'show' ] ) && false === $field [ 'show' ] ) {
continue ;
}
2013-08-06 10:41:20 +00:00
2014-06-11 19:50:15 +00:00
$field_name = 'shipping_' . $key ;
2013-08-06 10:41:20 +00:00
2014-06-11 19:50:15 +00:00
if ( ! empty ( $order -> $field_name ) ) {
echo '<p><strong>' . esc_html ( $field [ 'label' ] ) . ':</strong> ' . make_clickable ( esc_html ( $order -> $field_name ) ) . '</p>' ;
}
}
2013-08-06 10:41:20 +00:00
}
2014-06-11 19:50:15 +00:00
if ( apply_filters ( 'woocommerce_enable_order_notes_field' , 'yes' == get_option ( 'woocommerce_enable_order_comments' , 'yes' ) ) && $post -> post_excerpt ) {
2013-10-04 12:31:43 +00:00
echo '<p><strong>' . __ ( 'Customer Note' , 'woocommerce' ) . ':</strong> ' . nl2br ( esc_html ( $post -> post_excerpt ) ) . '</p>' ;
2014-06-11 19:50:15 +00:00
}
2013-08-16 15:43:26 +00:00
2013-08-06 10:41:20 +00:00
echo '</div>' ;
// Display form
2014-06-11 19:50:15 +00:00
echo '<div class="edit_address"><p><button class="button load_customer_shipping">' . __ ( 'Load shipping address' , 'woocommerce' ) . '</button> <button class="button billing-same-as-shipping">' . __ ( 'Copy from billing' , 'woocommerce' ) . '</button></p>' ;
2013-08-06 10:41:20 +00:00
2014-06-11 19:50:15 +00:00
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 ;
}
2013-08-06 10:41:20 +00:00
}
}
2014-06-11 19:50:15 +00:00
if ( apply_filters ( 'woocommerce_enable_order_notes_field' , 'yes' == get_option ( 'woocommerce_enable_order_comments' , 'yes' ) ) ) {
2013-08-16 15:43:26 +00:00
?>
< p class = " form-field form-field-wide " >< label for = " excerpt " >< ? php _e ( 'Customer Note:' , 'woocommerce' ) ?> </label>
< textarea rows = " 1 " cols = " 40 " name = " excerpt " tabindex = " 6 " id = " excerpt " placeholder = " <?php _e( 'Customer \ 's notes about the order', 'woocommerce' ); ?> " >< ? php echo wp_kses_post ( $post -> post_excerpt ); ?> </textarea></p>
< ? php
}
2013-08-06 10:41:20 +00:00
echo '</div>' ;
do_action ( 'woocommerce_admin_order_data_after_shipping_address' , $order );
?>
</ div >
</ div >
< div class = " clear " ></ div >
</ div >
</ div >
< ? php
// Ajax Chosen Customer Selectors JS
2013-09-12 13:41:02 +00:00
wc_enqueue_js ( "
2014-06-11 19:50:15 +00:00
jQuery ( 'select.ajax_chosen_select_customer' ) . ajaxChosen ({
method : 'GET' ,
url : '" . admin_url( ' admin - ajax . php ' ) . "' ,
dataType : 'json' ,
afterTypeDelay : 100 ,
minTermLength : 1 ,
data : {
action : 'woocommerce_json_search_customers' ,
security : '" . wp_create_nonce( ' search - customers ' ) . "'
}
}, function ( data ) {
2013-08-06 10:41:20 +00:00
var terms = {};
2014-06-11 19:50:15 +00:00
$ . each ( data , function ( i , val ) {
terms [ i ] = val ;
});
2013-08-06 10:41:20 +00:00
2014-06-11 19:50:15 +00:00
return terms ;
2013-08-06 10:41:20 +00:00
});
" );
}
/**
* Save meta box data
*/
public static function save ( $post_id , $post ) {
global $wpdb ;
self :: init_address_fields ();
// Add key
add_post_meta ( $post_id , '_order_key' , uniqid ( 'order_' ), true );
// Update meta
update_post_meta ( $post_id , '_customer_user' , absint ( $_POST [ 'customer_user' ] ) );
2014-06-11 19:50:15 +00:00
if ( self :: $billing_fields ) {
foreach ( self :: $billing_fields as $key => $field ) {
2013-11-25 13:34:21 +00:00
update_post_meta ( $post_id , '_billing_' . $key , wc_clean ( $_POST [ '_billing_' . $key ] ) );
2014-06-11 19:50:15 +00:00
}
}
2013-08-06 10:41:20 +00:00
2014-06-11 19:50:15 +00:00
if ( self :: $shipping_fields ) {
foreach ( self :: $shipping_fields as $key => $field ) {
2013-11-25 13:34:21 +00:00
update_post_meta ( $post_id , '_shipping_' . $key , wc_clean ( $_POST [ '_shipping_' . $key ] ) );
2014-06-11 19:50:15 +00:00
}
}
2013-08-06 10:41:20 +00:00
2014-06-27 12:12:10 +00:00
if ( isset ( $_POST [ '_transaction_id' ] ) ) {
update_post_meta ( $post_id , '_transaction_id' , wc_clean ( $_POST [ '_transaction_id' ] ) );
}
2013-08-16 15:43:26 +00:00
// Payment method handling
if ( get_post_meta ( $post_id , '_payment_method' , true ) !== stripslashes ( $_POST [ '_payment_method' ] ) ) {
2014-06-11 19:50:15 +00:00
$methods = WC () -> payment_gateways -> payment_gateways ();
$payment_method = wc_clean ( $_POST [ '_payment_method' ] );
$payment_method_title = $payment_method ;
2013-08-16 15:43:26 +00:00
2014-06-11 19:50:15 +00:00
if ( isset ( $methods ) && isset ( $methods [ $payment_method ] ) ) {
2013-08-16 15:43:26 +00:00
$payment_method_title = $methods [ $payment_method ] -> get_title ();
2014-06-11 19:50:15 +00:00
}
2013-08-16 15:43:26 +00:00
update_post_meta ( $post_id , '_payment_method' , $payment_method );
update_post_meta ( $post_id , '_payment_method_title' , $payment_method_title );
}
2013-08-06 10:41:20 +00:00
// 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' );
}
2013-08-17 00:19:56 +00: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 ) );
2013-08-06 10:41:20 +00:00
// Order data saved, now get it so we can manipulate status
2014-08-15 12:29:21 +00:00
$order = wc_get_order ( $post_id );
2013-08-06 10:41:20 +00:00
// Order status
$order -> update_status ( $_POST [ 'order_status' ] );
2014-02-26 15:43:19 +00:00
wc_delete_shop_order_transients ( $post_id );
2013-08-06 10:41:20 +00:00
}
2014-06-11 20:12:23 +00:00
}