Optimisations + order details template
This commit is contained in:
parent
111f444da7
commit
dae7cf35a2
|
@ -294,7 +294,6 @@ class woocommerce_product {
|
|||
return apply_filters('woocommerce_product_title', apply_filters('the_title', $this->post->post_title), $this);
|
||||
}
|
||||
|
||||
|
||||
/** Get the add to url */
|
||||
function add_to_cart_url() {
|
||||
global $woocommerce;
|
||||
|
@ -315,9 +314,8 @@ class woocommerce_product {
|
|||
|
||||
/** Returns whether or not the product is stock managed */
|
||||
function managing_stock() {
|
||||
if (get_option('woocommerce_manage_stock')=='yes') :
|
||||
if (isset($this->manage_stock) && $this->manage_stock=='yes') return true;
|
||||
endif;
|
||||
if (!isset($this->manage_stock) || $this->manage_stock=='no') return false;
|
||||
if (get_option('woocommerce_manage_stock')=='yes') return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -464,8 +462,7 @@ class woocommerce_product {
|
|||
|
||||
foreach ($this->get_children() as $child_id) :
|
||||
$sale_price = get_post_meta( $child_id, 'sale_price', true );
|
||||
$regular_price = get_post_meta( $child_id, 'price', true );
|
||||
if ( $sale_price > 0 && $sale_price < $regular_price ) return true;
|
||||
if ( $sale_price >= 0 ) return true;
|
||||
endforeach;
|
||||
|
||||
else :
|
||||
|
|
|
@ -0,0 +1,129 @@
|
|||
<?php
|
||||
/**
|
||||
* Order Details
|
||||
*/
|
||||
|
||||
global $woocommerce, $order_id;
|
||||
|
||||
$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>
|
||||
<th scope="row" colspan="2"><?php _e('Cart Subtotal:', 'woothemes'); ?></th>
|
||||
<td><?php echo $order->get_subtotal_to_display(); ?></td>
|
||||
</tr>
|
||||
<?php if ($order->get_cart_discount() > 0) : ?><tr>
|
||||
<th scope="row" colspan="2"><?php _e('Cart Discount:', 'woothemes'); ?></th>
|
||||
<td><?php echo woocommerce_price($order->get_cart_discount()); ?></td>
|
||||
</tr><?php endif; ?>
|
||||
<?php if ($order->get_shipping() > 0) : ?><tr>
|
||||
<th scope="row" colspan="2"><?php _e('Shipping:', 'woothemes'); ?></th>
|
||||
<td><?php echo $order->get_shipping_to_display(); ?></td>
|
||||
</tr><?php endif; ?>
|
||||
<?php if ($order->get_total_tax() > 0) : ?><tr>
|
||||
<th scope="row" colspan="2"><?php echo $woocommerce->countries->tax_or_vat(); ?></th>
|
||||
<td><?php echo woocommerce_price($order->get_total_tax()); ?></td>
|
||||
</tr><?php endif; ?>
|
||||
<?php if ($order->get_order_discount() > 0) : ?><tr>
|
||||
<th scope="row" colspan="2"><?php _e('Order Discount:', 'woothemes'); ?></th>
|
||||
<td><?php echo woocommerce_price($order->get_order_discount()); ?></td>
|
||||
</tr><?php endif; ?>
|
||||
<tr>
|
||||
<th scope="row" colspan="2"><?php _e('Order Total:', 'woothemes'); ?></th>
|
||||
<td><?php echo woocommerce_price($order->get_order_total()); ?></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'];
|
||||
|
||||
$item_meta = &new order_item_meta( $item['item_meta'] );
|
||||
$item_meta->display();
|
||||
|
||||
echo ' </td>
|
||||
<td>'.$item['qty'].'</td>
|
||||
<td>';
|
||||
|
||||
if ($order->display_cart_ex_tax || !$order->prices_include_tax) :
|
||||
if ($order->prices_include_tax) $ex_tax_label = 1; else $ex_tax_label = 0;
|
||||
echo woocommerce_price( $order->get_row_cost( $item, false ), array('ex_tax_label' => $ex_tax_label ));
|
||||
else :
|
||||
echo woocommerce_price( $order->get_row_cost( $item, true ) );
|
||||
endif;
|
||||
|
||||
echo '</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>
|
|
@ -64,17 +64,7 @@ class WooCommerce_Widget_Cart extends WP_Widget {
|
|||
echo '</ul>';
|
||||
|
||||
if (sizeof($woocommerce->cart->get_cart())>0) :
|
||||
echo '<p class="total"><strong>';
|
||||
|
||||
if (get_option('js_prices_include_tax')=='yes') :
|
||||
_e('Total', 'woothemes');
|
||||
else :
|
||||
_e('Subtotal', 'woothemes');
|
||||
endif;
|
||||
|
||||
echo ':</strong> '.$woocommerce->cart->get_cart_total();
|
||||
|
||||
echo '</p>';
|
||||
echo '<p class="total"><strong>' . __('Subtotal', 'woothemes') . ':</strong> '. $woocommerce->cart->get_cart_total() . '</p>';
|
||||
|
||||
do_action( 'woocommerce_widget_shopping_cart_before_buttons' );
|
||||
|
||||
|
|
|
@ -7,13 +7,15 @@
|
|||
* @author WooThemes
|
||||
*/
|
||||
|
||||
if (is_active_widget( false, false, 'woocommerce_layered_nav', 'true' ) && !is_admin()) :
|
||||
add_action('init', 'woocommerce_layered_nav_init', 1);
|
||||
add_filter('loop_shop_post_in', 'woocommerce_layered_nav_query');
|
||||
endif;
|
||||
|
||||
/**
|
||||
* Layered Nav Init
|
||||
*/
|
||||
if (!is_admin()) add_action('init', 'woocommerce_layered_nav_init', 1);
|
||||
|
||||
function woocommerce_layered_nav_init() {
|
||||
|
||||
global $_chosen_attributes, $woocommerce;
|
||||
|
||||
$_chosen_attributes = array();
|
||||
|
@ -44,10 +46,7 @@ function woocommerce_layered_nav_init() {
|
|||
/**
|
||||
* Layered Nav post filter
|
||||
*/
|
||||
add_filter('loop_shop_post_in', 'woocommerce_layered_nav_query');
|
||||
|
||||
function woocommerce_layered_nav_query( $filtered_posts ) {
|
||||
|
||||
global $_chosen_attributes, $woocommerce;
|
||||
|
||||
if (sizeof($_chosen_attributes)>0) :
|
||||
|
|
|
@ -9,11 +9,14 @@
|
|||
* @author WooThemes
|
||||
*/
|
||||
|
||||
if (is_active_widget( false, false, 'woocommerce_price_filter', 'true' ) && !is_admin()) :
|
||||
add_action('init', 'woocommerce_price_filter_init');
|
||||
add_filter('loop_shop_post_in', 'woocommerce_price_filter');
|
||||
endif;
|
||||
|
||||
/**
|
||||
* Price filter Init
|
||||
*/
|
||||
add_action('init', 'woocommerce_price_filter_init');
|
||||
|
||||
function woocommerce_price_filter_init() {
|
||||
|
||||
unset($_SESSION['min_price']);
|
||||
|
@ -31,8 +34,6 @@ function woocommerce_price_filter_init() {
|
|||
/**
|
||||
* Price Filter post filter
|
||||
*/
|
||||
add_filter('loop_shop_post_in', 'woocommerce_price_filter');
|
||||
|
||||
function woocommerce_price_filter( $filtered_posts ) {
|
||||
|
||||
if (isset($_GET['max_price']) && isset($_GET['min_price'])) :
|
||||
|
|
|
@ -88,14 +88,6 @@ function woocommerce_email_content_type($content_type){
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Fix recieve password mail links
|
||||
**/
|
||||
function woocommerce_retrieve_password_message($content){
|
||||
return htmlspecialchars($content);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Hooks for emails
|
||||
**/
|
||||
|
|
|
@ -476,7 +476,6 @@ if (!function_exists('woocommerce_get_product_thumbnail')) {
|
|||
**/
|
||||
if (!function_exists('woocommerce_output_related_products')) {
|
||||
function woocommerce_output_related_products() {
|
||||
// 2 Related Products in 2 columns
|
||||
woocommerce_related_products( 2, 2 );
|
||||
}
|
||||
}
|
||||
|
@ -502,8 +501,8 @@ if (!function_exists('woocommerce_related_products')) {
|
|||
query_posts($args);
|
||||
woocommerce_get_template_part( 'loop', 'shop' );
|
||||
echo '</div>';
|
||||
endif;
|
||||
wp_reset_query();
|
||||
endif;
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -616,8 +615,6 @@ if (!function_exists('woocommerce_breadcrumb')) {
|
|||
|
||||
elseif ( is_tax('product_cat') ) :
|
||||
|
||||
//echo $before . '<a href="' . get_post_type_archive_link('product') . '">' . ucwords(get_option('woocommerce_shop_slug')) . '</a>' . $after . $delimiter;
|
||||
|
||||
$term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) );
|
||||
|
||||
$parents = array();
|
||||
|
@ -771,7 +768,6 @@ if (!function_exists('woocommerce_breadcrumb')) {
|
|||
echo $wrap_after;
|
||||
|
||||
endif;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -834,9 +830,9 @@ function woocommerce_order_review() {
|
|||
* Adds a demo store banner to the site if enabled
|
||||
**/
|
||||
function woocommerce_demo_store() {
|
||||
if (get_option('woocommerce_demo_store')=='yes') :
|
||||
echo '<p class="demo_store">'.__('This is a demo store for testing purposes — no orders shall be fulfilled.', 'woothemes').'</p>';
|
||||
endif;
|
||||
if (get_option('woocommerce_demo_store')=='no') return;
|
||||
|
||||
echo apply_filters('woocommerce_demo_store', '<p class="demo_store">'.__('This is a demo store for testing purposes — no orders shall be fulfilled.', 'woothemes').'</p>' );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -940,138 +936,16 @@ function woocommerce_subcategory_thumbnail( $category ) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Display an orders details in a table
|
||||
* Displays order details in a table
|
||||
**/
|
||||
function woocommerce_order_details_table( $order_id ) {
|
||||
global $woocommerce;
|
||||
function woocommerce_order_details_table( $id ) {
|
||||
global $woocommerce, $order_id;
|
||||
|
||||
if (!$order_id) return;
|
||||
if (!$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>
|
||||
<th scope="row" colspan="2"><?php _e('Cart Subtotal:', 'woothemes'); ?></th>
|
||||
<td><?php echo $order->get_subtotal_to_display(); ?></td>
|
||||
</tr>
|
||||
<?php if ($order->get_cart_discount() > 0) : ?><tr>
|
||||
<th scope="row" colspan="2"><?php _e('Cart Discount:', 'woothemes'); ?></th>
|
||||
<td><?php echo woocommerce_price($order->get_cart_discount()); ?></td>
|
||||
</tr><?php endif; ?>
|
||||
<?php if ($order->get_shipping() > 0) : ?><tr>
|
||||
<th scope="row" colspan="2"><?php _e('Shipping:', 'woothemes'); ?></th>
|
||||
<td><?php echo $order->get_shipping_to_display(); ?></td>
|
||||
</tr><?php endif; ?>
|
||||
<?php if ($order->get_total_tax() > 0) : ?><tr>
|
||||
<th scope="row" colspan="2"><?php echo $woocommerce->countries->tax_or_vat(); ?></th>
|
||||
<td><?php echo woocommerce_price($order->get_total_tax()); ?></td>
|
||||
</tr><?php endif; ?>
|
||||
<?php if ($order->get_order_discount() > 0) : ?><tr>
|
||||
<th scope="row" colspan="2"><?php _e('Order Discount:', 'woothemes'); ?></th>
|
||||
<td><?php echo woocommerce_price($order->get_order_discount()); ?></td>
|
||||
</tr><?php endif; ?>
|
||||
<tr>
|
||||
<th scope="row" colspan="2"><?php _e('Order Total:', 'woothemes'); ?></th>
|
||||
<td><?php echo woocommerce_price($order->get_order_total()); ?></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) :
|
||||
$order_id = $id;
|
||||
|
||||
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'];
|
||||
|
||||
$item_meta = &new order_item_meta( $item['item_meta'] );
|
||||
$item_meta->display();
|
||||
|
||||
echo ' </td>
|
||||
<td>'.$item['qty'].'</td>
|
||||
<td>';
|
||||
|
||||
if (!isset($item['base_cost'])) $item['base_cost'] = $item['cost'];
|
||||
|
||||
if ($order->display_cart_ex_tax || !$order->prices_include_tax) :
|
||||
if ($order->prices_include_tax) $ex_tax_label = 1; else $ex_tax_label = 0;
|
||||
echo woocommerce_price( $item['base_cost']*$item['qty'], array('ex_tax_label' => $ex_tax_label ));
|
||||
else :
|
||||
echo woocommerce_price( round(($item['base_cost']*$item['qty']) * (($item['taxrate']/100) + 1), 2) );
|
||||
endif;
|
||||
|
||||
echo '</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
|
||||
woocommerce_get_template('order/order-details-table.php', false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue