get order number function complete with filter. Tweak the display of order ID's if you use custom numbering.

Had to tweak some localisation strings to dump the '#' symbols.
This commit is contained in:
Mike Jolley 2012-03-26 11:26:50 +01:00
parent b6557a4930
commit 659d3ee3b4
15 changed files with 32 additions and 18 deletions

View File

@ -230,7 +230,7 @@ class WC_Email {
$order = $pay_for_order;
$email_heading = sprintf(__('Invoice for Order #%s', 'woocommerce'), $order->id);
$email_heading = sprintf( __('Invoice for Order %s', 'woocommerce'), $order->get_order_number() );
$blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);

View File

@ -144,6 +144,19 @@ class WC_Order {
return false;
}
/**
* get_order_number function.
*
* Gets the order number for display (by default, order ID)
*
* @access public
* @return string
*/
function get_order_number() {
return apply_filters( 'woocommerce_order_number', '#' . $this->id, $this );
}
function get_formatted_billing_address() {
if (!$this->formatted_billing_address) :
global $woocommerce;

View File

@ -251,7 +251,7 @@ class WC_Paypal extends WC_Payment_Gateway {
if ($item['qty']) $item_names[] = $item['name'] . ' x ' . $item['qty'];
endforeach; endif;
$paypal_args['item_name_1'] = sprintf(__('Order #%s' , 'woocommerce'), $order->id) . " - " . implode(', ', $item_names);
$paypal_args['item_name_1'] = sprintf( __('Order %s' , 'woocommerce'), $order->get_order_number() ) . " - " . implode(', ', $item_names);
$paypal_args['quantity_1'] = 1;
$paypal_args['amount_1'] = number_format($order->get_order_total() - $order->get_shipping() + $order->get_order_discount(), 2, '.', '');
@ -549,11 +549,11 @@ class WC_Paypal extends WC_Payment_Gateway {
$message = woocommerce_mail_template(
__('Order refunded/reversed', 'woocommerce'),
sprintf(__('Order #%s has been marked as refunded - PayPal reason code: %s', 'woocommerce'), $order->id, $posted['reason_code'] )
sprintf(__('Order %s has been marked as refunded - PayPal reason code: %s', 'woocommerce'), $order->get_order_number(), $posted['reason_code'] )
);
// Send the mail
woocommerce_mail( get_option('woocommerce_new_order_email_recipient'), sprintf(__('Payment for order #%s refunded/reversed', 'woocommerce'), $order->id), $message );
woocommerce_mail( get_option('woocommerce_new_order_email_recipient'), sprintf( __('Payment for order %s refunded/reversed', 'woocommerce'), $order->get_order_number() ), $message );
}
@ -566,11 +566,11 @@ class WC_Paypal extends WC_Payment_Gateway {
$message = woocommerce_mail_template(
__('Order refunded/reversed', 'woocommerce'),
sprintf(__('Order #%s has been marked as refunded - PayPal reason code: %s', 'woocommerce'), $order->id, $posted['reason_code'] )
sprintf(__('Order %s has been marked as refunded - PayPal reason code: %s', 'woocommerce'), $order->get_order_number(), $posted['reason_code'] )
);
// Send the mail
woocommerce_mail( get_option('woocommerce_new_order_email_recipient'), sprintf(__('Payment for order #%s refunded/reversed', 'woocommerce'), $order->id), $message );
woocommerce_mail( get_option('woocommerce_new_order_email_recipient'), sprintf( __('Payment for order %s refunded/reversed', 'woocommerce'), $order->get_order_number() ), $message );
break;
default:

View File

@ -148,6 +148,7 @@ Yes you can! Join in on our [GitHub repository](http://github.com/woothemes/wooc
* Feature - Control default catalog sort order from Catalog Settings
* Feature - Option to use post instead of get to submit paypal standard - form also has target="_top" to work when in iframes
* Feature - Local delivery postcode limiting
* Tweak - get order number function complete with filter
* Tweak - View cart link in 'you already have this in your cart' message
* Tweak - When viewing a product, give shop menu item a class
* Tweak - Layered nav dropdown code to filter displayed terms based on view

View File

@ -260,7 +260,7 @@ function woocommerce_view_order() {
$status = get_term_by('slug', $order->status, 'shop_order_status');
echo '<p>'
. sprintf( __('Order <mark>#%s</mark> made on <mark>%s</mark>', 'woocommerce'), $order->id, date_i18n(get_option('date_format'), strtotime($order->order_date)) )
. sprintf( __('Order <mark>%s</mark> made on <mark>%s</mark>', 'woocommerce'), $order->get_order_number(), date_i18n(get_option('date_format'), strtotime($order->order_date)) )
. sprintf( __('. Order status: <mark>%s</mark>', 'woocommerce'), __($status->name, 'woocommerce') )
. '.</p>';

View File

@ -71,7 +71,7 @@ function woocommerce_pay() {
<ul class="order_details">
<li class="order">
<?php _e('Order:', 'woocommerce'); ?>
<strong># <?php echo $order->id; ?></strong>
<strong><?php echo $order->get_order_number(); ?></strong>
</li>
<li class="date">
<?php _e('Date:', 'woocommerce'); ?>

View File

@ -34,7 +34,7 @@ global $woocommerce;
<ul class="order_details">
<li class="order">
<?php _e('Order:', 'woocommerce'); ?>
<strong># <?php echo $order->id; ?></strong>
<strong><?php echo $order->get_order_number(); ?></strong>
</li>
<li class="date">
<?php _e('Date:', 'woocommerce'); ?>

View File

@ -6,7 +6,7 @@
<?php do_action('woocommerce_email_before_order_table', $order, true); ?>
<h2><?php echo __('Order #:', 'woocommerce') . ' ' . $order->id; ?></h2>
<h2><?php echo __('Order:', 'woocommerce') . ' ' . $order->get_order_number(); ?></h2>
<table cellspacing="0" cellpadding="6" style="width: 100%; border: 1px solid #eee;" border="1" bordercolor="#eee">
<thead>

View File

@ -6,7 +6,7 @@
<?php do_action('woocommerce_email_before_order_table', $order, false); ?>
<h2><?php echo __('Order #:', 'woocommerce') . ' ' . $order->id; ?></h2>
<h2><?php echo __('Order:', 'woocommerce') . ' ' . $order->get_order_number(); ?></h2>
<table cellspacing="0" cellpadding="6" style="width: 100%; border: 1px solid #eee;" border="1" bordercolor="#eee">
<thead>

View File

@ -10,7 +10,7 @@
<?php do_action('woocommerce_email_before_order_table', $order, false); ?>
<h2><?php echo __('Order #', 'woocommerce') . $order->id; ?></h2>
<h2><?php echo __('Order:', 'woocommerce') . ' ' . $order->get_order_number(); ?></h2>
<table cellspacing="0" cellpadding="6" style="width: 100%; border: 1px solid #eee;" border="1" bordercolor="#eee">
<thead>

View File

@ -10,7 +10,7 @@
<?php do_action('woocommerce_email_before_order_table', $order, false); ?>
<h2><?php echo __('Order #:', 'woocommerce') . ' ' . $order->id; ?></h2>
<h2><?php echo __('Order:', 'woocommerce') . ' ' . $order->get_order_number(); ?></h2>
<table cellspacing="0" cellpadding="6" style="width: 100%; border: 1px solid #eee;" border="1" bordercolor="#eee">
<thead>

View File

@ -6,7 +6,7 @@
<?php do_action('woocommerce_email_before_order_table', $order, false); ?>
<h2><?php echo __('Order #:', 'woocommerce') . ' ' . $order->id; ?></h2>
<h2><?php echo __('Order:', 'woocommerce') . ' ' . $order->get_order_number(); ?></h2>
<table cellspacing="0" cellpadding="6" style="width: 100%; border: 1px solid #eee;" border="1" bordercolor="#eee">
<thead>

View File

@ -52,7 +52,7 @@ if ($customer_orders) :
$order = new WC_Order();
$order->populate($customer_order);
?><tr class="order">
<td class="order-number"><?php echo $order->id; ?></td>
<td class="order-number"><?php echo $order->get_order_number(); ?></td>
<td class="order-date"><time title="<?php echo esc_attr( strtotime($order->order_date) ); ?>"><?php echo date_i18n(get_option('date_format'), strtotime($order->order_date)); ?></time></td>
<td class="order-shipto"><address><?php if ($order->get_formatted_shipping_address()) echo $order->get_formatted_shipping_address(); else echo '&ndash;'; ?></address></td>
<td class="order-total"><?php echo woocommerce_price($order->order_total); ?></td>

View File

@ -9,7 +9,7 @@ global $woocommerce;
<?php
$status = get_term_by('slug', $order->status, 'shop_order_status');
$order_status_text = sprintf( __('Order #%s which was made %s has the status &ldquo;%s&rdquo;', 'woocommerce'), $order->id, human_time_diff(strtotime($order->order_date), current_time('timestamp')).__(' ago', 'woocommerce'), __($status->name, 'woocommerce') );
$order_status_text = sprintf( __('Order %s which was made %s has the status &ldquo;%s&rdquo;', 'woocommerce'), $order->get_order_number(), human_time_diff(strtotime($order->order_date), current_time('timestamp')).__(' ago', 'woocommerce'), __($status->name, 'woocommerce') );
if ($order->status == 'completed') $order_status_text .= ' ' . __('and was completed', 'woocommerce') . ' ' . human_time_diff(strtotime($order->completed_date), current_time('timestamp')).__(' ago', 'woocommerce');