Added order details to thanks page. Closes #121.

Added hooks for thanks page + view order page so that order tables can
use the same code. This also means you can unhook the order table if
you don't wan't it on the thanks page.
This commit is contained in:
Mike Jolley 2011-10-31 00:47:41 +00:00
parent 75ed1f4efd
commit 5575b92a50
5 changed files with 153 additions and 138 deletions

View File

@ -89,6 +89,7 @@ Yes you can! Join in on our GitHub repository :) https://github.com/woothemes/wo
* Download urls use site_url instead of home_url so installs in subdirectories are handled correctly
* Option to add logout link to my account menu
* Ability to preview email templates
* Added order details to thankyou page
= 1.1.3 - 27/10/2011 =
* Improved Force SSL Setting - now forces https urls for enqueued scripts and styles

View File

@ -471,143 +471,31 @@ function woocommerce_view_order() {
echo sprintf( __('. Order status: <mark>%s</mark>', 'woothemes'), $status->name );
echo '.</p>';
?>
$notes = $order->get_customer_order_notes();
if ($notes) :
?>
<h2><?php _e('Order Updates', 'woothemes'); ?></h2>
<ol class="commentlist notes">
<?php foreach ($notes as $note) : ?>
<li class="comment note">
<div class="comment_container">
<div class="comment-text">
<p class="meta"><?php echo date_i18n('l jS \of F Y, h:ia', strtotime($note->comment_date)); ?></p>
<div class="description">
<?php echo wpautop(wptexturize($note->comment_content)); ?>
</div>
<div class="clear"></div>
</div>
<div class="clear"></div>
</div>
</li>
<?php endforeach; ?>
</ol>
<?php
endif;
<?php
$notes = $order->get_customer_order_notes();
if ($notes) :
?>
<h2><?php _e('Order Updates', 'woothemes'); ?></h2>
<ol class="commentlist notes">
<?php foreach ($notes as $note) : ?>
<li class="comment note">
<div class="comment_container">
<div class="comment-text">
<p class="meta"><?php echo date_i18n('l jS \of F Y, h:ia', strtotime($note->comment_date)); ?></p>
<div class="description">
<?php echo wpautop(wptexturize($note->comment_content)); ?>
</div>
<div class="clear"></div>
</div>
<div class="clear"></div>
</div>
</li>
<?php endforeach; ?>
</ol>
<?php
endif;
?>
<h2><?php _e('Order Details', 'woothemes'); ?></h2>
<table class="shop_table">
<thead>
<tr>
<th><?php _e('Product', 'woothemes'); ?></th>
<th><?php _e('Qty', 'woothemes'); ?></th>
<th><?php _e('Totals', 'woothemes'); ?></th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="2"><?php _e('Subtotal', 'woothemes'); ?></td>
<td><?php echo $order->get_subtotal_to_display(); ?></td>
</tr>
<?php if ($order->order_shipping>0) : ?><tr>
<td colspan="2"><?php _e('Shipping', 'woothemes'); ?></td>
<td><?php echo $order->get_shipping_to_display(); ?></small></td>
</tr><?php endif; ?>
<?php if ($order->get_total_tax()>0) : ?><tr>
<td colspan="2"><?php _e('Tax', 'woothemes'); ?></td>
<td><?php echo woocommerce_price($order->get_total_tax()); ?></td>
</tr><?php endif; ?>
<?php if ($order->order_discount>0) : ?><tr class="discount">
<td colspan="2"><?php _e('Discount', 'woothemes'); ?></td>
<td>-<?php echo woocommerce_price($order->order_discount); ?></td>
</tr><?php endif; ?>
<tr>
<td colspan="2"><strong><?php _e('Grand Total', 'woothemes'); ?></strong></td>
<td><strong><?php echo woocommerce_price($order->order_total); ?></strong></td>
</tr>
<?php if ($order->customer_note) : ?>
<tr>
<td><?php _e('Note:', 'woothemes'); ?></td>
<td colspan="2"><?php echo wpautop(wptexturize($order->customer_note)); ?></td>
</tr>
<?php endif; ?>
</tfoot>
<tbody>
<?php
if (sizeof($order->items)>0) :
foreach($order->items as $item) :
if (isset($item['variation_id']) && $item['variation_id'] > 0) :
$_product = &new woocommerce_product_variation( $item['variation_id'] );
else :
$_product = &new woocommerce_product( $item['id'] );
endif;
echo '
<tr>
<td class="product-name">'.$item['name'];
if (isset($item['item_meta'])) :
echo woocommerce_get_formatted_variation( $item['item_meta'] );
endif;
echo ' </td>
<td>'.$item['qty'].'</td>
<td>'.woocommerce_price( $item['cost']*$item['qty'], array('ex_tax_label' => 1) ).'</td>
</tr>';
endforeach;
endif;
?>
</tbody>
</table>
<header>
<h2><?php _e('Customer details', 'woothemes'); ?></h2>
</header>
<dl>
<?php
if ($order->billing_email) echo '<dt>'.__('Email:', 'woothemes').'</dt><dd>'.$order->billing_email.'</dd>';
if ($order->billing_phone) echo '<dt>'.__('Telephone:', 'woothemes').'</dt><dd>'.$order->billing_phone.'</dd>';
?>
</dl>
<div class="col2-set addresses">
<div class="col-1">
<header class="title">
<h3><?php _e('Shipping Address', 'woothemes'); ?></h3>
</header>
<address><p>
<?php
if (!$order->formatted_shipping_address) _e('N/A', 'woothemes'); else echo $order->formatted_shipping_address;
?>
</p></address>
</div><!-- /.col-1 -->
<div class="col-2">
<header class="title">
<h3><?php _e('Billing Address', 'woothemes'); ?></h3>
</header>
<address><p>
<?php
if (!$order->formatted_billing_address) _e('N/A', 'woothemes'); else echo $order->formatted_billing_address;
?>
</p></address>
</div><!-- /.col-2 -->
</div><!-- /.col2-set -->
<div class="clear"></div>
<?php
do_action( 'woocommerce_view_order', $order_id );
else :

View File

@ -52,7 +52,7 @@ function woocommerce_thankyou( $atts ) {
if (is_user_logged_in()) :
echo '<a href="'.esc_url( get_permalink(get_option('woocommerce_myaccount_page_id')) ).'" class="button pay">'.__('My Account', 'woothemes').'</a>';
endif;
else :
echo '<p>' . __('Thank you. Your order has been received.', 'woothemes') . '</p>';
@ -85,8 +85,8 @@ function woocommerce_thankyou( $atts ) {
endif;
do_action( 'woocommerce_thankyou', $order_id );
do_action( 'woocommerce_thankyou_' . $order->payment_method, $order_id );
do_action( 'woocommerce_thankyou', $order_id );
endif;

View File

@ -92,3 +92,7 @@ add_action('woocommerce_cart_collaterals', 'woocommerce_cross_sell_display');
/* Footer */
add_action( 'wp_footer', 'woocommerce_demo_store' );
/* Order details */
add_action( 'woocommerce_view_order', 'woocommerce_order_details_table', 10 );
add_action( 'woocommerce_thankyou', 'woocommerce_order_details_table', 10 );

View File

@ -1156,6 +1156,9 @@ function woocommerce_product_subcategories() {
}
/**
* Show subcategory thumbnail
**/
function woocommerce_subcategory_thumbnail( $category ) {
global $woocommerce;
@ -1175,3 +1178,122 @@ function woocommerce_subcategory_thumbnail( $category ) {
echo '<img src="'.$image.'" alt="'.$category->slug.'" width="'.$image_width.'" height="'.$image_height.'" />';
}
/**
* Display an orders details in a table
**/
function woocommerce_order_details_table( $order_id ) {
if (!$order_id) return;
$order = &new woocommerce_order( $order_id );
?>
<h2><?php _e('Order Details', 'woothemes'); ?></h2>
<table class="shop_table">
<thead>
<tr>
<th><?php _e('Product', 'woothemes'); ?></th>
<th><?php _e('Qty', 'woothemes'); ?></th>
<th><?php _e('Totals', 'woothemes'); ?></th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="2"><?php _e('Subtotal', 'woothemes'); ?></td>
<td><?php echo $order->get_subtotal_to_display(); ?></td>
</tr>
<?php if ($order->order_shipping>0) : ?><tr>
<td colspan="2"><?php _e('Shipping', 'woothemes'); ?></td>
<td><?php echo $order->get_shipping_to_display(); ?></small></td>
</tr><?php endif; ?>
<?php if ($order->get_total_tax()>0) : ?><tr>
<td colspan="2"><?php _e('Tax', 'woothemes'); ?></td>
<td><?php echo woocommerce_price($order->get_total_tax()); ?></td>
</tr><?php endif; ?>
<?php if ($order->order_discount>0) : ?><tr class="discount">
<td colspan="2"><?php _e('Discount', 'woothemes'); ?></td>
<td>-<?php echo woocommerce_price($order->order_discount); ?></td>
</tr><?php endif; ?>
<tr>
<td colspan="2"><strong><?php _e('Grand Total', 'woothemes'); ?></strong></td>
<td><strong><?php echo woocommerce_price($order->order_total); ?></strong></td>
</tr>
<?php if ($order->customer_note) : ?>
<tr>
<td><?php _e('Note:', 'woothemes'); ?></td>
<td colspan="2"><?php echo wpautop(wptexturize($order->customer_note)); ?></td>
</tr>
<?php endif; ?>
</tfoot>
<tbody>
<?php
if (sizeof($order->items)>0) :
foreach($order->items as $item) :
if (isset($item['variation_id']) && $item['variation_id'] > 0) :
$_product = &new woocommerce_product_variation( $item['variation_id'] );
else :
$_product = &new woocommerce_product( $item['id'] );
endif;
echo '
<tr>
<td class="product-name">'.$item['name'];
if (isset($item['item_meta'])) :
echo woocommerce_get_formatted_variation( $item['item_meta'] );
endif;
echo ' </td>
<td>'.$item['qty'].'</td>
<td>'.woocommerce_price( $item['cost']*$item['qty'], array('ex_tax_label' => 1) ).'</td>
</tr>';
endforeach;
endif;
?>
</tbody>
</table>
<header>
<h2><?php _e('Customer details', 'woothemes'); ?></h2>
</header>
<dl>
<?php
if ($order->billing_email) echo '<dt>'.__('Email:', 'woothemes').'</dt><dd>'.$order->billing_email.'</dd>';
if ($order->billing_phone) echo '<dt>'.__('Telephone:', 'woothemes').'</dt><dd>'.$order->billing_phone.'</dd>';
?>
</dl>
<div class="col2-set addresses">
<div class="col-1">
<header class="title">
<h3><?php _e('Shipping Address', 'woothemes'); ?></h3>
</header>
<address><p>
<?php
if (!$order->formatted_shipping_address) _e('N/A', 'woothemes'); else echo $order->formatted_shipping_address;
?>
</p></address>
</div><!-- /.col-1 -->
<div class="col-2">
<header class="title">
<h3><?php _e('Billing Address', 'woothemes'); ?></h3>
</header>
<address><p>
<?php
if (!$order->formatted_billing_address) _e('N/A', 'woothemes'); else echo $order->formatted_billing_address;
?>
</p></address>
</div><!-- /.col-2 -->
</div><!-- /.col2-set -->
<div class="clear"></div>
<?php
}