Admin formatted address

This commit is contained in:
Mike Jolley 2011-12-18 13:41:42 +00:00
parent 17a59bf3ec
commit 18cc9a9442
6 changed files with 53 additions and 50 deletions

View File

@ -47,8 +47,6 @@ function woocommerce_custom_order_columns($column) {
break;
case "order_title" :
echo '<a href="'.admin_url('post.php?post='.$post->ID.'&action=edit').'">'.sprintf( __('Order #%s', 'woothemes'), $post->ID ).'</a> ';
if ($order->user_id) $user_info = get_userdata($order->user_id);
if (isset($user_info) && $user_info) :
@ -64,7 +62,7 @@ function woocommerce_custom_order_columns($column) {
$user = __('Guest', 'woothemes');
endif;
echo '<small class="meta">' . __('Customer:', 'woothemes') . ' ' . $user . '</small>';
echo '<a href="'.admin_url('post.php?post='.$post->ID.'&action=edit').'"><strong>'.sprintf( __('Order #%s', 'woothemes'), $post->ID ).'</strong></a> ' . __('made by', 'woothemes') . ' ' . $user;
if ($order->billing_email) :
echo '<small class="meta">'.__('Email:', 'woothemes') . ' ' . '<a href="' . esc_url( 'mailto:'.$order->billing_email ).'">'.esc_html( $order->billing_email ).'</a></small>';
@ -75,10 +73,8 @@ function woocommerce_custom_order_columns($column) {
break;
case "billing_address" :
echo '<strong>'.esc_html( $order->billing_first_name . ' ' . $order->billing_last_name );
if ($order->billing_company) echo ', '.esc_html( $order->billing_company );
echo '</strong><br/>';
echo '<a target="_blank" href="' . esc_url( 'http://maps.google.co.uk/maps?&q='.urlencode($order->formatted_billing_address).'&z=16' ) . '">'.esc_html( $order->formatted_billing_address ).'</a>';
echo '<a target="_blank" href="' . esc_url( 'http://maps.google.co.uk/maps?&q='.urlencode( $order->billing_address_only ).'&z=16' ) . '">'. preg_replace('#<br\s*/?>#i', ', ', $order->formatted_billing_address) .'</a>';
if ($order->payment_method_title) :
echo '<small class="meta">' . __('Paid via', 'woothemes') . ' ' . esc_html( $order->payment_method_title ) . '</small>';
@ -87,10 +83,8 @@ function woocommerce_custom_order_columns($column) {
break;
case "shipping_address" :
if ($order->formatted_shipping_address) :
echo '<strong>'.esc_html( $order->shipping_first_name . ' ' . $order->shipping_last_name );
if ($order->shipping_company) : echo ', '.esc_html( $order->shipping_company ); endif;
echo '</strong><br/>';
echo '<a target="_blank" href="' . esc_url( 'http://maps.google.co.uk/maps?&q='.urlencode($order->formatted_shipping_address).'&z=16' ) .'">'.esc_html( $order->formatted_shipping_address ).'</a>';
echo '<a target="_blank" href="' . esc_url( 'http://maps.google.co.uk/maps?&q='.urlencode( $order->shipping_address_only ).'&z=16' ) .'">'. preg_replace('#<br\s*/?>#i', ', ', $order->formatted_shipping_address) .'</a>';
else :
echo '&ndash;';
endif;

View File

@ -903,7 +903,7 @@ jQuery(function(){
// Frontend Chosen selects
jQuery("select.country_select, select.state_select").chosen();
$('body').bind('country_to_state_changed', function(){
jQuery('body').bind('country_to_state_changed', function(){
jQuery("select.state_select").chosen().trigger("liszt:updated");
});

File diff suppressed because one or more lines are too long

View File

@ -622,6 +622,9 @@ class woocommerce_countries {
// Handle full country name
$full_country = (isset($this->countries[$country])) ? $this->countries[$country] : $country;
// Handle full state name
$full_state = ($country && $state && isset($this->states[$country][$state])) ? $this->states[$country][$state] : $state;
// Substitute address parts into the string
$search = array(
'{first_name}',
@ -654,7 +657,7 @@ class woocommerce_countries {
$address_1,
$address_2,
$city,
$state,
$full_state,
$postcode,
$full_country,
strtoupper($first_name),
@ -664,7 +667,7 @@ class woocommerce_countries {
strtoupper($address_1),
strtoupper($address_2),
strtoupper($city),
strtoupper($state),
strtoupper($full_state),
strtoupper($postcode),
strtoupper($full_country),
);

View File

@ -106,40 +106,46 @@ class woocommerce_order {
endforeach;
// Formatted Addresses
$formatted_address = array();
$address = array(
'first_name' => $this->billing_first_name,
'last_name' => $this->billing_last_name,
'company' => $this->billing_company,
'address_1' => $this->billing_address_1,
'address_2' => $this->billing_address_2,
'city' => $this->billing_city,
'state' => $this->billing_state,
'postcode' => $this->billing_postcode,
'country' => $this->billing_country
);
$country = ($this->billing_country && isset($woocommerce->countries->countries[$this->billing_country])) ? $woocommerce->countries->countries[$this->billing_country] : $this->billing_country;
$this->formatted_billing_address = $woocommerce->countries->get_formatted_address( $address );
$state = ($this->billing_country && $this->billing_state && isset($woocommerce->countries->states[$this->billing_country][$this->billing_state])) ? $woocommerce->countries->states[$this->billing_country][$this->billing_state] : $this->billing_state;
$address = array_map('trim', array(
$this->billing_address_1,
$this->billing_address_2,
$this->billing_city,
$state,
$this->billing_postcode,
$country
));
foreach ($address as $part) if (!empty($part)) $formatted_address[] = $part;
$this->formatted_billing_address = implode(', ', $formatted_address);
unset($address['first_name']);
unset($address['last_name']);
unset($address['company']);
foreach ($address as $part) if (!empty($part)) $joined_address[] = $part;
$this->billing_address_only = implode(', ', $joined_address);
if ($this->shipping_address_1) :
$formatted_address = array();
$address = array(
'first_name' => $this->shipping_first_name,
'last_name' => $this->shipping_last_name,
'company' => $this->shipping_company,
'address_1' => $this->shipping_address_1,
'address_2' => $this->shipping_address_2,
'city' => $this->shipping_city,
'state' => $this->shipping_state,
'postcode' => $this->shipping_postcode,
'country' => $this->shipping_country
);
$country = ($this->shipping_country && isset($woocommerce->countries->countries[$this->shipping_country])) ? $woocommerce->countries->countries[$this->shipping_country] : $this->shipping_country;
$this->formatted_shipping_address = $woocommerce->countries->get_formatted_address( $address );
$state = ($this->shipping_country && $this->shipping_state && isset($woocommerce->countries->states[$this->shipping_country][$this->shipping_state])) ? $woocommerce->countries->states[$this->shipping_country][$this->shipping_state] : $this->shipping_state;
$address = array_map('trim', array(
$this->shipping_address_1,
$this->shipping_address_2,
$this->shipping_city,
$state,
$this->shipping_postcode,
$country
));
foreach ($address as $part) if (!empty($part)) $formatted_address[] = $part;
$this->formatted_shipping_address = implode(', ', $formatted_address);
unset($address['first_name']);
unset($address['last_name']);
unset($address['company']);
foreach ($address as $part) if (!empty($part)) $joined_address[] = $part;
$this->shipping_address_only = implode(', ', $joined_address);
endif;
// Taxonomy data