Order data/fixed keys. Closes #1981.

This commit is contained in:
Mike Jolley 2012-12-13 00:47:40 +00:00
parent 3af034755b
commit 7976ae8a66
5 changed files with 129 additions and 105 deletions

View File

@ -49,82 +49,95 @@ function woocommerce_order_data_meta_box($post) {
$order_title = $post->post_title;
?>
<style type="text/css">
#titlediv, #major-publishing-actions, #minor-publishing-actions, #visibility, #submitdiv { display:none }
#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 esc_attr( $order_title ); ?>" />
<input name="post_status" type="hidden" value="publish" />
<div id="order_data" class="panel">
<div class="order_data_left">
<h2><?php _e( 'Order Details', 'woocommerce' ); ?></h2>
<p class="order_number"><?php
<h2><?php _e( 'Order Details', 'woocommerce' ); ?> &mdash; <?php echo esc_html( $order->get_order_number() ); ?></h2>
echo __( 'Order number', 'woocommerce' ) . ' ' . esc_html( $order->get_order_number() ) . '. ';
<p class="form-field"><label for="order_status"><?php _e( 'Order status:', 'woocommerce' ) ?></label>
<select id="order_status" name="order_status" class="chosen_select">
<?php
$statuses = (array) get_terms( 'shop_order_status', array( 'hide_empty' => 0, 'orderby' => 'id' ) );
foreach ( $statuses as $status ) {
echo '<option value="' . esc_attr( $status->slug ) . '" ' . selected( $status->slug, $order_status, false ) . '>' . esc_html__( $status->name, 'woocommerce' ) . '</option>';
}
?>
</select></p>
$ip_address = get_post_meta( $post->ID, '_customer_ip_address', true );
<p class="form-field last"><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>
if ( $ip_address )
echo __( 'Customer IP:', 'woocommerce' ) . ' ' . esc_html( $ip_address );
<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>
?></p>
<div class="order_data_column_container">
<div class="order_data_column">
<h4><?php _e( 'General Details', 'woocommerce' ); ?></h4>
<p class="form-field"><label for="order_status"><?php _e( 'Order status:', 'woocommerce' ) ?></label>
<select id="order_status" name="order_status" class="chosen_select">
<?php
if ( $customer_user ) {
$user = get_user_by( 'id', $customer_user );
echo '<option value="' . esc_attr( $user->ID ) . '" ' . selected( 1, 1, false ) . '>' . esc_html( $user->display_name ) . ' (#' . absint( $user->ID ) . ' &ndash; ' . esc_html( $user->user_email ) . ')</option>';
$statuses = (array) get_terms( 'shop_order_status', array( 'hide_empty' => 0, 'orderby' => 'id' ) );
foreach ( $statuses as $status ) {
echo '<option value="' . esc_attr( $status->slug ) . '" ' . selected( $status->slug, $order_status, false ) . '>' . esc_html__( $status->name, 'woocommerce' ) . '</option>';
}
?>
</select>
<?php
</select></p>
// Ajax Chosen Customer Selectors JS
$woocommerce->add_inline_js( "
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) {
<p class="form-field last"><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>
var terms = {};
<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 ( $customer_user ) {
$user = get_user_by( 'id', $customer_user );
echo '<option value="' . esc_attr( $user->ID ) . '" ' . selected( 1, 1, false ) . '>' . esc_html( $user->display_name ) . ' (#' . absint( $user->ID ) . ' &ndash; ' . esc_html( $user->user_email ) . ')</option>';
}
?>
</select>
<?php
$.each(data, function (i, val) {
terms[i] = val;
});
// Ajax Chosen Customer Selectors JS
$woocommerce->add_inline_js( "
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) {
return terms;
});
" );
var terms = {};
?>
</p>
$.each(data, function (i, val) {
terms[i] = val;
});
<?php if( get_option( 'woocommerce_enable_order_comments' ) != 'no' ) : ?>
<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 endif; ?>
return terms;
});
" );
?>
</p>
<?php do_action( 'woocommerce_admin_order_data_after_order_details', $order ); ?>
<?php if ( get_option( 'woocommerce_enable_order_comments' ) != 'no' ) : ?>
</div>
<div class="order_data_right">
<div class="order_data">
<h2><?php _e( 'Billing Details', 'woocommerce' ); ?> <a class="edit_address" href="#">(<?php _e( 'Edit', 'woocommerce' ) ;?>)</a></h2>
<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 endif; ?>
<?php do_action( 'woocommerce_admin_order_data_after_order_details', $order ); ?>
</div>
<div class="order_data_column">
<h4><?php _e( 'Billing Details', 'woocommerce' ); ?> <a class="edit_address" href="#">(<?php _e( 'Edit', 'woocommerce' ) ;?>)</a></h4>
<?php
$billing_data = apply_filters('woocommerce_admin_billing_fields', array(
'first_name' => array(
@ -182,7 +195,7 @@ function woocommerce_order_data_meta_box($post) {
echo '<p class="none_set"><strong>' . __( 'Address', 'woocommerce' ) . ':</strong> ' . __( 'No billing address set.', 'woocommerce' ) . '</p>';
foreach ( $billing_data as $key => $field ) {
if ( empty( $field['show'] ) )
if ( isset( $field['show'] ) && $field['show'] === false )
continue;
$field_name = 'billing_' . $key;
if ( $order->$field_name )
@ -212,9 +225,9 @@ function woocommerce_order_data_meta_box($post) {
do_action( 'woocommerce_admin_order_data_after_billing_address', $order );
?>
</div>
<div class="order_data order_data_alt">
<div class="order_data_column">
<h2><?php _e( 'Shipping Details', 'woocommerce' ); ?> <a class="edit_address" href="#">(<?php _e( 'Edit', 'woocommerce' ) ;?>)</a></h2>
<h4><?php _e( 'Shipping Details', 'woocommerce' ); ?> <a class="edit_address" href="#">(<?php _e( 'Edit', 'woocommerce' ) ;?>)</a></h4>
<?php
$shipping_data = apply_filters('woocommerce_admin_shipping_fields', array(
'first_name' => array(
@ -266,7 +279,7 @@ function woocommerce_order_data_meta_box($post) {
echo '<p class="none_set"><strong>' . __( 'Address', 'woocommerce' ) . ':</strong> ' . __( 'No shipping address set.', 'woocommerce' ) . '</p>';
if ( $shipping_data ) foreach ( $shipping_data as $key => $field ) {
if ( empty( $field['show'] ) )
if ( isset( $field['show'] ) && $field['show'] === false )
continue;
$field_name = 'shipping_' . $key;
if ( $order->$field_name )

File diff suppressed because one or more lines are too long

View File

@ -446,14 +446,48 @@ ul.wc_coupon_list_block {
display: inline-block;
vertical-align: middle;
}
#woocommerce-order-data {
h3.hndle, .handlediv {
display: none;
}
.inside {
display: block !important;
}
}
#order_data {
padding: 0 10px 9px;
.order_data_left {
width: 48%;
padding: 23px 24px 12px 24px;
h2 {
margin: 0;
font-family: "HelveticaNeue-Light","Helvetica Neue Light","Helvetica Neue",sans-serif;
font-size: 21px;
font-weight: normal;
line-height: 1.2;
text-shadow: 1px 1px 1px white;
padding: 0;
}
h4 {
color: #333;
margin: 1.33em 0 0;
}
p {
color: #777;
}
p.order_number {
margin: 0;
font-family: "HelveticaNeue-Light","Helvetica Neue Light","Helvetica Neue",sans-serif;
font-weight: normal;
line-height: 1.6em;
font-size: 16px;
}
.order_data_column_container {
clear: both;
}
.order_data_column {
width: 32%;
padding: 0 2% 0 0;
float: left;
h2 {
margin-top: 11px;
margin-bottom: 0;
&:last-child {
padding-right: 0;
}
p {
padding: 0 !important;
@ -487,6 +521,11 @@ ul.wc_coupon_list_block {
.hour, .minute {
width: 2.5em;
}
small {
display: block;
margin: 5px 0 0 0;
color: #999;
}
}
.form-field.last {
float: right;
@ -501,48 +540,20 @@ ul.wc_coupon_list_block {
width: 100%;
}
}
}
.order_data_right {
width: 48%;
float: right;
.order_data {
overflow: hidden;
zoom: 1;
width: 49%;
float:left;
}
.order_data_alt {
float:right;
}
h2 {
margin-top: 11px;
margin-bottom: 0;
}
p {
padding: 0 !important;
}
p.none_set {
color: #999;
}
.form-field {
._billing_first_name_field, ._billing_address_1_field, ._billing_city_field, ._billing_country_field, ._billing_email_field,
._shipping_first_name_field, ._shipping_address_1_field, ._shipping_city_field, ._shipping_country_field {
float: left;
width: 50%;
padding: 0;
margin: 9px 0 0 0;
label {
display: block;
padding: 0 0 3px;
}
input, select {
width: 95%;
}
}
._billing_last_name_field, ._billing_address_2_field, ._billing_postcode_field, ._billing_state_field, ._billing_phone_field,
._shipping_last_name_field, ._shipping_address_2_field, ._shipping_postcode_field, ._shipping_state_field {
float: right;
}
._billing_company_field, ._shipping_company_field {
clear: both;
width: 100%;
input {
width: 97.5%;
}
}
._billing_email_field {
clear: left
@ -551,6 +562,7 @@ ul.wc_coupon_list_block {
display: none;
overflow: hidden;
zoom: 1;
padding-right: 1px;
}
}
}

View File

@ -171,10 +171,9 @@ jQuery( function($){
});
$('a.edit_address').click(function(event){
$(this).hide();
$(this).closest('.order_data').find('div.address').hide();
$(this).closest('.order_data').find('div.edit_address').show();
$(this).closest('.order_data_column').find('div.address').hide();
$(this).closest('.order_data_column').find('div.edit_address').show();
event.preventDefault();
});

File diff suppressed because one or more lines are too long