View order tweaks
* Tweak - Changed recent order tables to make them slightly more compact * Tweak - Moved recent order table to a template file * Tweak - Improved default view-order page when order id is not defined - instead of stating "invalid order" it will list recent orders
This commit is contained in:
parent
6363420508
commit
7ccefed4d7
|
@ -146,6 +146,9 @@ Yes you can! Join in on our [GitHub repository](http://github.com/woothemes/wooc
|
|||
= 1.5.4 =
|
||||
* Feature - Allow attributes to be added from the edit product page
|
||||
* Feature - Allow external products to be a part of a grouped product. Button titles will be respected when displayed.
|
||||
* Tweak - Changed recent order tables to make them slightly more compact
|
||||
* Tweak - Moved recent order table to a template file
|
||||
* Tweak - Improved default view-order page when order id is not defined - instead of stating "invalid order" it will list recent orders
|
||||
* Tweak - For the short description, removed the_content filter and used woocommerce_short_description
|
||||
* Tweak - Don't send password in new account email (some customers complained/privacy concerns)
|
||||
* Tweak - Don't show unused tabs on the frontend (description and reviews)
|
||||
|
|
|
@ -249,13 +249,18 @@ function woocommerce_view_order() {
|
|||
if ( ! is_user_logged_in() ) return;
|
||||
|
||||
$user_id = get_current_user_id();
|
||||
$order_id = (isset($_GET['order'])) ? $_GET['order'] : 0;
|
||||
$order_id = ( isset( $_GET['order'] ) ) ? $_GET['order'] : 0;
|
||||
$order = new WC_Order( $order_id );
|
||||
|
||||
if ( $order_id==0 || $order->user_id != $user_id ) :
|
||||
|
||||
if ( $order_id == 0 ) {
|
||||
woocommerce_get_template('myaccount/my-orders.php', array( 'recent_orders' => 10 ));
|
||||
return;
|
||||
}
|
||||
|
||||
if ( $order->user_id != $user_id ) {
|
||||
echo '<div class="woocommerce_error">' . __('Invalid order.', 'woocommerce') . ' <a href="'.get_permalink( woocommerce_get_page_id('myaccount') ).'">'. __('My Account →', 'woocommerce') .'</a>' . '</div>';
|
||||
return;
|
||||
endif;
|
||||
}
|
||||
|
||||
$status = get_term_by('slug', $order->status, 'shop_order_status');
|
||||
|
||||
|
|
|
@ -22,63 +22,7 @@ global $woocommerce;
|
|||
<?php endif; ?>
|
||||
|
||||
<h2><?php _e('Recent Orders', 'woocommerce'); ?></h2>
|
||||
<?php
|
||||
$customer_id = get_current_user_id();
|
||||
|
||||
$args = array(
|
||||
'numberposts' => $recent_orders,
|
||||
'meta_key' => '_customer_user',
|
||||
'meta_value' => $customer_id,
|
||||
'post_type' => 'shop_order',
|
||||
'post_status' => 'publish'
|
||||
);
|
||||
$customer_orders = get_posts($args);
|
||||
if ($customer_orders) :
|
||||
?>
|
||||
<table class="shop_table my_account_orders">
|
||||
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="order-number"><span class="nobr"><?php _e('#', 'woocommerce'); ?></span></th>
|
||||
<th class="order-date"><span class="nobr"><?php _e('Date', 'woocommerce'); ?></span></th>
|
||||
<th class="order-shipto"><span class="nobr"><?php _e('Ship to', 'woocommerce'); ?></span></th>
|
||||
<th class="order-total"><span class="nobr"><?php _e('Total', 'woocommerce'); ?></span></th>
|
||||
<th class="order-status" colspan="2"><span class="nobr"><?php _e('Status', 'woocommerce'); ?></span></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody><?php
|
||||
foreach ($customer_orders as $customer_order) :
|
||||
$order = new WC_Order();
|
||||
$order->populate($customer_order);
|
||||
?><tr class="order">
|
||||
<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 '–'; ?></address></td>
|
||||
<td class="order-total"><?php echo woocommerce_price($order->order_total); ?></td>
|
||||
<td class="order-status"><?php
|
||||
$status = get_term_by('slug', $order->status, 'shop_order_status');
|
||||
echo __($status->name, 'woocommerce');
|
||||
?></td>
|
||||
<td class="order-actions" style="text-align:right; white-space:nowrap;">
|
||||
<?php if (in_array($order->status, array('pending', 'failed'))) : ?>
|
||||
<a href="<?php echo esc_url( $order->get_checkout_payment_url() ); ?>" class="button pay"><?php _e('Pay', 'woocommerce'); ?></a>
|
||||
<a href="<?php echo esc_url( $order->get_cancel_order_url() ); ?>" class="button cancel"><?php _e('Cancel', 'woocommerce'); ?></a>
|
||||
<?php endif; ?>
|
||||
<a href="<?php echo esc_url( add_query_arg('order', $order->id, get_permalink(woocommerce_get_page_id('view_order'))) ); ?>" class="button"><?php _e('View', 'woocommerce'); ?></a>
|
||||
</td>
|
||||
</tr><?php
|
||||
endforeach;
|
||||
?></tbody>
|
||||
|
||||
</table>
|
||||
<?php
|
||||
else :
|
||||
?>
|
||||
<p><?php _e('You have no recent orders.', 'woocommerce'); ?></p>
|
||||
<?php
|
||||
endif;
|
||||
?>
|
||||
<?php woocommerce_get_template('myaccount/my-orders.php', array( 'recent_orders' => $recent_orders )); ?>
|
||||
|
||||
<h2><?php _e('My Address', 'woocommerce'); ?></h2>
|
||||
<p><?php _e('The following addresses will be used on the checkout page by default.', 'woocommerce'); ?></p>
|
||||
|
|
|
@ -0,0 +1,75 @@
|
|||
<?php
|
||||
/**
|
||||
* My Orders
|
||||
*
|
||||
* Shows recent orders on the account page
|
||||
*/
|
||||
|
||||
global $woocommerce;
|
||||
|
||||
$customer_id = get_current_user_id();
|
||||
|
||||
$args = array(
|
||||
'numberposts' => $recent_orders,
|
||||
'meta_key' => '_customer_user',
|
||||
'meta_value' => $customer_id,
|
||||
'post_type' => 'shop_order',
|
||||
'post_status' => 'publish'
|
||||
);
|
||||
$customer_orders = get_posts($args);
|
||||
|
||||
if ($customer_orders) :
|
||||
?>
|
||||
<table class="shop_table my_account_orders">
|
||||
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="order-number"><span class="nobr"><?php _e('Order', 'woocommerce'); ?></span></th>
|
||||
<th class="order-shipto"><span class="nobr"><?php _e('Ship to', 'woocommerce'); ?></span></th>
|
||||
<th class="order-total"><span class="nobr"><?php _e('Total', 'woocommerce'); ?></span></th>
|
||||
<th class="order-status" colspan="2"><span class="nobr"><?php _e('Status', 'woocommerce'); ?></span></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody><?php
|
||||
foreach ($customer_orders as $customer_order) :
|
||||
$order = new WC_Order();
|
||||
|
||||
$order->populate( $customer_order );
|
||||
|
||||
$status = get_term_by('slug', $order->status, 'shop_order_status');
|
||||
|
||||
?><tr class="order">
|
||||
<td class="order-number" width="1%">
|
||||
<a href="<?php echo esc_url( add_query_arg('order', $order->id, get_permalink(woocommerce_get_page_id('view_order'))) ); ?>"><?php echo $order->get_order_number(); ?></a> – <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 '–'; ?></address></td>
|
||||
<td class="order-total" width="1%"><?php echo woocommerce_price($order->order_total); ?></td>
|
||||
<td class="order-status" style="text-align:left; white-space:nowrap;">
|
||||
<?php echo ucfirst( __( $status->name, 'woocommerce' ) ); ?>
|
||||
<?php if (in_array($order->status, array('pending', 'failed'))) : ?>
|
||||
<a href="<?php echo esc_url( $order->get_cancel_order_url() ); ?>" class="cancel" title="<?php _e('Click to cancel this order', 'woocommerce'); ?>">(<?php _e('Cancel', 'woocommerce'); ?>)</a>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td class="order-actions" style="text-align:right; white-space:nowrap;">
|
||||
|
||||
<?php if (in_array($order->status, array('pending', 'failed'))) : ?>
|
||||
<a href="<?php echo esc_url( $order->get_checkout_payment_url() ); ?>" class="button pay"><?php _e('Pay', 'woocommerce'); ?></a>
|
||||
<?php endif; ?>
|
||||
|
||||
<a href="<?php echo esc_url( add_query_arg('order', $order->id, get_permalink(woocommerce_get_page_id('view_order'))) ); ?>" class="button"><?php _e('View', 'woocommerce'); ?></a>
|
||||
|
||||
|
||||
</td>
|
||||
</tr><?php
|
||||
endforeach;
|
||||
?></tbody>
|
||||
|
||||
</table>
|
||||
<?php
|
||||
else :
|
||||
?>
|
||||
<p><?php _e('You have no recent orders.', 'woocommerce'); ?></p>
|
||||
<?php
|
||||
endif;
|
||||
?>
|
Loading…
Reference in New Issue