Futher standardisation of cart and order loops. Closes #3348.
This commit is contained in:
parent
97cd97ddda
commit
3b5d8b7d41
|
@ -2118,6 +2118,21 @@ class WC_Cart {
|
||||||
return apply_filters( 'woocommerce_cart_subtotal', $cart_subtotal, $compound, $this );
|
return apply_filters( 'woocommerce_cart_subtotal', $cart_subtotal, $compound, $this );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the product row price per item.
|
||||||
|
*
|
||||||
|
* @params object product
|
||||||
|
* @return string formatted price
|
||||||
|
*/
|
||||||
|
public function get_product_price( $_product ) {
|
||||||
|
if ( $this->tax_display_cart == 'excl' )
|
||||||
|
$product_price = $_product->get_price_excluding_tax();
|
||||||
|
else
|
||||||
|
$product_price = $_product->get_price_including_tax();
|
||||||
|
|
||||||
|
return apply_filters( 'woocommerce_cart_product_price', woocommerce_price( $product_price ), $_product );
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the product row subtotal.
|
* Get the product row subtotal.
|
||||||
*
|
*
|
||||||
|
|
|
@ -12,8 +12,39 @@
|
||||||
|
|
||||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||||
|
|
||||||
|
|
||||||
function woocommerce_show_messages() {
|
function woocommerce_show_messages() {
|
||||||
_deprecated_function( 'woocommerce_show_messages', '2.1', 'wc_print_messages' );
|
_deprecated_function( 'woocommerce_show_messages', '2.1', 'wc_print_messages' );
|
||||||
wc_show_messages();
|
wc_show_messages();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle renamed filters
|
||||||
|
*/
|
||||||
|
global $wc_map_deprecated_filters;
|
||||||
|
|
||||||
|
$wc_map_deprecated_filters = array(
|
||||||
|
'woocommerce_cart_item_class' => 'woocommerce_cart_table_item_class',
|
||||||
|
'woocommerce_cart_item_product_id' => 'hook_woocommerce_in_cart_product_id',
|
||||||
|
'woocommerce_cart_item_thumbnail' => 'hook_woocommerce_in_cart_product_thumbnail',
|
||||||
|
'woocommerce_cart_item_price' => 'woocommerce_cart_item_price_html',
|
||||||
|
'woocommerce_cart_item_name' => 'woocommerce_in_cart_product_title',
|
||||||
|
'woocommerce_order_item_class' => 'woocommerce_order_table_item_class',
|
||||||
|
'woocommerce_order_item_name' => 'woocommerce_order_table_product_title'
|
||||||
|
);
|
||||||
|
|
||||||
|
foreach ( $wc_map_deprecated_filters as $new => $old )
|
||||||
|
add_filter( $new, 'woocommerce_deprecated_filter_mapping' );
|
||||||
|
|
||||||
|
function woocommerce_deprecated_filter_mapping( $data, $arg_1 = '', $arg_2 = '', $arg_3 = '' ) {
|
||||||
|
global $wc_map_deprecated_filters;
|
||||||
|
|
||||||
|
$filter = current_filter();
|
||||||
|
|
||||||
|
if ( isset( $wc_map_deprecated_filters[ $filter ] ) )
|
||||||
|
if ( has_filter( $wc_map_deprecated_filters[ $filter ] ) ) {
|
||||||
|
$data = apply_filters( $wc_map_deprecated_filters[ $filter ], $arg_1, $arg_2, $arg_3 );
|
||||||
|
_deprecated_function( 'The ' . $wc_map_deprecated_filters[ $filter ] . ' filter', '2.1', $filter );
|
||||||
|
}
|
||||||
|
|
||||||
|
return $data;
|
||||||
}
|
}
|
|
@ -4,7 +4,7 @@
|
||||||
*
|
*
|
||||||
* @author WooThemes
|
* @author WooThemes
|
||||||
* @package WooCommerce/Templates
|
* @package WooCommerce/Templates
|
||||||
* @version 1.6.4
|
* @version 2.1.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||||
|
@ -12,9 +12,8 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||||
global $woocommerce;
|
global $woocommerce;
|
||||||
|
|
||||||
wc_print_messages();
|
wc_print_messages();
|
||||||
?>
|
|
||||||
|
|
||||||
<?php do_action( 'woocommerce_before_cart' ); ?>
|
do_action( 'woocommerce_before_cart' ); ?>
|
||||||
|
|
||||||
<form action="<?php echo esc_url( $woocommerce->cart->get_cart_url() ); ?>" method="post">
|
<form action="<?php echo esc_url( $woocommerce->cart->get_cart_url() ); ?>" method="post">
|
||||||
|
|
||||||
|
@ -35,86 +34,77 @@ wc_print_messages();
|
||||||
<?php do_action( 'woocommerce_before_cart_contents' ); ?>
|
<?php do_action( 'woocommerce_before_cart_contents' ); ?>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
if ( sizeof( $woocommerce->cart->get_cart() ) > 0 ) {
|
foreach ( $woocommerce->cart->get_cart() as $cart_item_key => $cart_item ) {
|
||||||
foreach ( $woocommerce->cart->get_cart() as $cart_item_key => $values ) {
|
$_product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key );
|
||||||
$_product = $values['data'];
|
$product_id = apply_filters( 'woocommerce_cart_item_product_id', $cart_item['product_id'], $cart_item, $cart_item_key );
|
||||||
$product_id = apply_filters('woocommerce_in_cart_product_id', $values['product_id'] );
|
|
||||||
|
|
||||||
if ( $_product->exists() && $values['quantity'] > 0 ) {
|
if ( $_product && $_product->exists() && $cart_item['quantity'] > 0 && apply_filters( 'woocommerce_cart_item_visible', true, $cart_item, $cart_item_key ) ) {
|
||||||
?>
|
?>
|
||||||
<tr class = "<?php echo esc_attr( apply_filters('woocommerce_cart_table_item_class', 'cart_table_item', $values, $cart_item_key ) ); ?>">
|
<tr class="<?php echo esc_attr( apply_filters( 'woocommerce_cart_item_class', 'cart_item', $cart_item, $cart_item_key ) ); ?>">
|
||||||
<!-- Remove from cart link -->
|
|
||||||
<td class="product-remove">
|
|
||||||
<?php
|
|
||||||
echo apply_filters( 'woocommerce_cart_item_remove_link', sprintf('<a href="%s" class="remove" title="%s">×</a>', esc_url( $woocommerce->cart->get_remove_url( $cart_item_key ) ), __( 'Remove this item', 'woocommerce' ) ), $cart_item_key );
|
|
||||||
?>
|
|
||||||
</td>
|
|
||||||
|
|
||||||
<!-- The thumbnail -->
|
<td class="product-remove">
|
||||||
<td class="product-thumbnail">
|
<?php
|
||||||
<?php
|
echo apply_filters( 'woocommerce_cart_item_remove_link', sprintf( '<a href="%s" class="remove" title="%s">×</a>', esc_url( $woocommerce->cart->get_remove_url( $cart_item_key ) ), __( 'Remove this item', 'woocommerce' ) ), $cart_item_key );
|
||||||
$thumbnail = apply_filters( 'woocommerce_in_cart_product_thumbnail', $_product->get_image(), $values, $cart_item_key );
|
?>
|
||||||
|
</td>
|
||||||
|
|
||||||
if ( ! $_product->is_visible() )
|
<td class="product-thumbnail">
|
||||||
echo $thumbnail;
|
<?php
|
||||||
else
|
$thumbnail = apply_filters( 'woocommerce_cart_item_thumbnail', $_product->get_image(), $cart_item, $cart_item_key );
|
||||||
printf('<a href="%s">%s</a>', get_permalink( $product_id ), $thumbnail );
|
|
||||||
?>
|
|
||||||
</td>
|
|
||||||
|
|
||||||
<!-- Product Name -->
|
if ( ! $_product->is_visible() )
|
||||||
<td class="product-name">
|
echo $thumbnail;
|
||||||
<?php
|
else
|
||||||
if ( ! $_product->is_visible() )
|
printf( '<a href="%s">%s</a>', get_permalink( $product_id ), $thumbnail );
|
||||||
echo apply_filters( 'woocommerce_in_cart_product_title', $_product->get_title(), $values, $cart_item_key );
|
?>
|
||||||
else
|
</td>
|
||||||
echo apply_filters( 'woocommerce_in_cart_product_title', sprintf( '<a href="%s">%s</a>', get_permalink( $product_id ), $_product->get_title() ), $values, $cart_item_key );
|
|
||||||
|
|
||||||
// Meta data
|
<td class="product-name">
|
||||||
echo $woocommerce->cart->get_item_data( $values );
|
<?php
|
||||||
|
if ( ! $_product->is_visible() )
|
||||||
|
echo apply_filters( 'woocommerce_cart_item_name', $_product->get_title(), $cart_item, $cart_item_key );
|
||||||
|
else
|
||||||
|
echo apply_filters( 'woocommerce_cart_item_name', sprintf( '<a href="%s">%s</a>', get_permalink( $product_id ), $_product->get_title() ), $cart_item, $cart_item_key );
|
||||||
|
|
||||||
// Backorder notification
|
// Meta data
|
||||||
if ( $_product->backorders_require_notification() && $_product->is_on_backorder( $values['quantity'] ) )
|
echo $woocommerce->cart->get_item_data( $cart_item );
|
||||||
echo '<p class="backorder_notification">' . __( 'Available on backorder', 'woocommerce' ) . '</p>';
|
|
||||||
?>
|
|
||||||
</td>
|
|
||||||
|
|
||||||
<!-- Product price -->
|
// Backorder notification
|
||||||
<td class="product-price">
|
if ( $_product->backorders_require_notification() && $_product->is_on_backorder( $cart_item['quantity'] ) )
|
||||||
<?php
|
echo '<p class="backorder_notification">' . __( 'Available on backorder', 'woocommerce' ) . '</p>';
|
||||||
$product_price = get_option('woocommerce_tax_display_cart') == 'excl' ? $_product->get_price_excluding_tax() : $_product->get_price_including_tax();
|
?>
|
||||||
|
</td>
|
||||||
|
|
||||||
echo apply_filters('woocommerce_cart_item_price_html', woocommerce_price( $product_price ), $values, $cart_item_key );
|
<td class="product-price">
|
||||||
?>
|
<?php
|
||||||
</td>
|
echo apply_filters( 'woocommerce_cart_item_price', $woocommerce->cart->get_product_price( $_product ), $cart_item, $cart_item_key );
|
||||||
|
?>
|
||||||
|
</td>
|
||||||
|
|
||||||
<!-- Quantity inputs -->
|
<td class="product-quantity">
|
||||||
<td class="product-quantity">
|
<?php
|
||||||
<?php
|
if ( $_product->is_sold_individually() ) {
|
||||||
if ( $_product->is_sold_individually() ) {
|
$product_quantity = sprintf( '1 <input type="hidden" name="cart[%s][qty]" value="1" />', $cart_item_key );
|
||||||
$product_quantity = sprintf( '1 <input type="hidden" name="cart[%s][qty]" value="1" />', $cart_item_key );
|
} else {
|
||||||
} else {
|
|
||||||
|
|
||||||
$step = apply_filters( 'woocommerce_quantity_input_step', '1', $_product );
|
$step = apply_filters( 'woocommerce_quantity_input_step', '1', $_product );
|
||||||
$min = apply_filters( 'woocommerce_quantity_input_min', '', $_product );
|
$min = apply_filters( 'woocommerce_quantity_input_min', '', $_product );
|
||||||
$max = apply_filters( 'woocommerce_quantity_input_max', $_product->backorders_allowed() ? '' : $_product->get_stock_quantity(), $_product );
|
$max = apply_filters( 'woocommerce_quantity_input_max', $_product->backorders_allowed() ? '' : $_product->get_stock_quantity(), $_product );
|
||||||
|
|
||||||
$product_quantity = sprintf( '<div class="quantity"><input type="number" name="cart[%s][qty]" step="%s" min="%s" max="%s" value="%s" size="4" title="' . _x( 'Qty', 'Product quantity input tooltip', 'woocommerce' ) . '" class="input-text qty text" maxlength="12" /></div>', $cart_item_key, $step, $min, $max, esc_attr( $values['quantity'] ) );
|
$product_quantity = sprintf( '<div class="quantity"><input type="number" name="cart[%s][qty]" step="%s" min="%s" max="%s" value="%s" size="4" title="' . _x( 'Qty', 'Product quantity input tooltip', 'woocommerce' ) . '" class="input-text qty text" maxlength="12" /></div>', $cart_item_key, $step, $min, $max, esc_attr( $cart_item['quantity'] ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
echo apply_filters( 'woocommerce_cart_item_quantity', $product_quantity, $cart_item_key );
|
echo apply_filters( 'woocommerce_cart_item_quantity', $product_quantity, $cart_item_key );
|
||||||
?>
|
?>
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<!-- Product subtotal -->
|
<td class="product-subtotal">
|
||||||
<td class="product-subtotal">
|
<?php
|
||||||
<?php
|
echo apply_filters( 'woocommerce_cart_item_subtotal', $woocommerce->cart->get_product_subtotal( $_product, $cart_item['quantity'] ), $cart_item, $cart_item_key );
|
||||||
echo apply_filters( 'woocommerce_cart_item_subtotal', $woocommerce->cart->get_product_subtotal( $_product, $values['quantity'] ), $values, $cart_item_key );
|
?>
|
||||||
?>
|
</td>
|
||||||
</td>
|
</tr>
|
||||||
</tr>
|
<?php
|
||||||
<?php
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
*
|
*
|
||||||
* @author WooThemes
|
* @author WooThemes
|
||||||
* @package WooCommerce/Templates
|
* @package WooCommerce/Templates
|
||||||
* @version 1.6.4
|
* @version 2.1.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||||
|
@ -20,35 +20,31 @@ global $woocommerce;
|
||||||
|
|
||||||
<?php if ( sizeof( $woocommerce->cart->get_cart() ) > 0 ) : ?>
|
<?php if ( sizeof( $woocommerce->cart->get_cart() ) > 0 ) : ?>
|
||||||
|
|
||||||
<?php foreach ( $woocommerce->cart->get_cart() as $cart_item_key => $cart_item ) :
|
<?php
|
||||||
|
foreach ( $woocommerce->cart->get_cart() as $cart_item_key => $cart_item ) {
|
||||||
|
$_product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key );
|
||||||
|
$product_id = apply_filters( 'woocommerce_cart_item_product_id', $cart_item['product_id'], $cart_item, $cart_item_key );
|
||||||
|
|
||||||
$_product = $cart_item['data'];
|
if ( $_product && $_product->exists() && $cart_item['quantity'] > 0 && apply_filters( 'woocommerce_widget_cart_item_visible', true, $cart_item, $cart_item_key ) ) {
|
||||||
|
|
||||||
// Only display if allowed
|
$product_name = apply_filters( 'woocommerce_cart_item_name', $_product->get_title(), $cart_item, $cart_item_key );
|
||||||
if ( ! apply_filters('woocommerce_widget_cart_item_visible', true, $cart_item, $cart_item_key ) || ! $_product->exists() || $cart_item['quantity'] == 0 )
|
$thumbnail = apply_filters( 'woocommerce_cart_item_thumbnail', $_product->get_image(), $cart_item, $cart_item_key );
|
||||||
continue;
|
$product_price = apply_filters( 'woocommerce_cart_item_price', $woocommerce->cart->get_product_price( $_product ), $cart_item, $cart_item_key );
|
||||||
|
|
||||||
// Get price
|
?>
|
||||||
$product_price = get_option( 'woocommerce_tax_display_cart' ) == 'excl' ? $_product->get_price_excluding_tax() : $_product->get_price_including_tax();
|
<li>
|
||||||
|
<a href="<?php echo get_permalink( $product_id ); ?>">
|
||||||
|
<?php echo $thumbnail . $product_name; ?>
|
||||||
|
</a>
|
||||||
|
|
||||||
$product_price = apply_filters( 'woocommerce_cart_item_price_html', woocommerce_price( $product_price ), $cart_item, $cart_item_key );
|
<?php echo $woocommerce->cart->get_item_data( $cart_item ); ?>
|
||||||
?>
|
|
||||||
|
|
||||||
<li>
|
<?php echo apply_filters( 'woocommerce_widget_cart_item_quantity', '<span class="quantity">' . sprintf( '%s × %s', $cart_item['quantity'], $product_price ) . '</span>', $cart_item, $cart_item_key ); ?>
|
||||||
<a href="<?php echo get_permalink( $cart_item['product_id'] ); ?>">
|
</li>
|
||||||
|
<?php
|
||||||
<?php echo $_product->get_image(); ?>
|
}
|
||||||
|
}
|
||||||
<?php echo apply_filters('woocommerce_widget_cart_product_title', $_product->get_title(), $_product ); ?>
|
?>
|
||||||
|
|
||||||
</a>
|
|
||||||
|
|
||||||
<?php echo $woocommerce->cart->get_item_data( $cart_item ); ?>
|
|
||||||
|
|
||||||
<?php echo apply_filters( 'woocommerce_widget_cart_item_quantity', '<span class="quantity">' . sprintf( '%s × %s', $cart_item['quantity'], $product_price ) . '</span>', $cart_item, $cart_item_key ); ?>
|
|
||||||
</li>
|
|
||||||
|
|
||||||
<?php endforeach; ?>
|
|
||||||
|
|
||||||
<?php else : ?>
|
<?php else : ?>
|
||||||
|
|
||||||
|
@ -71,4 +67,4 @@ global $woocommerce;
|
||||||
|
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
||||||
<?php do_action( 'woocommerce_after_mini_cart' ); ?>
|
<?php do_action( 'woocommerce_after_mini_cart' ); ?>
|
|
@ -4,7 +4,7 @@
|
||||||
*
|
*
|
||||||
* @author WooThemes
|
* @author WooThemes
|
||||||
* @package WooCommerce/Templates
|
* @package WooCommerce/Templates
|
||||||
* @version 1.6.4
|
* @version 2.1.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||||
|
@ -115,22 +115,24 @@ $available_methods = $woocommerce->shipping->get_available_shipping_methods();
|
||||||
<?php
|
<?php
|
||||||
do_action( 'woocommerce_review_order_before_cart_contents' );
|
do_action( 'woocommerce_review_order_before_cart_contents' );
|
||||||
|
|
||||||
if (sizeof($woocommerce->cart->get_cart())>0) :
|
foreach ( $woocommerce->cart->get_cart() as $cart_item_key => $cart_item ) {
|
||||||
foreach ($woocommerce->cart->get_cart() as $cart_item_key => $values) :
|
$_product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key );
|
||||||
$_product = $values['data'];
|
|
||||||
if ($_product->exists() && $values['quantity']>0) :
|
if ( $_product && $_product->exists() && $cart_item['quantity'] > 0 && apply_filters( 'woocommerce_checkout_cart_item_visible', true, $cart_item, $cart_item_key ) ) {
|
||||||
echo '
|
?>
|
||||||
<tr class="' . esc_attr( apply_filters('woocommerce_checkout_table_item_class', 'checkout_table_item', $values, $cart_item_key ) ) . '">
|
<tr class="<?php echo esc_attr( apply_filters( 'woocommerce_cart_item_class', 'cart_item', $cart_item, $cart_item_key ) ); ?>">
|
||||||
<td class="product-name">' .
|
<td class="product-name">
|
||||||
apply_filters( 'woocommerce_checkout_product_title', $_product->get_title(), $_product ) . ' ' .
|
<?php echo apply_filters( 'woocommerce_cart_item_name', $_product->get_title(), $cart_item, $cart_item_key ); ?>
|
||||||
apply_filters( 'woocommerce_checkout_item_quantity', '<strong class="product-quantity">× ' . $values['quantity'] . '</strong>', $values, $cart_item_key ) .
|
<?php echo apply_filters( 'woocommerce_checkout_cart_item_quantity', ' <strong class="product-quantity">' . sprintf( '× %s', $cart_item['quantity'] ) . '</strong>', $cart_item, $cart_item_key ); ?>
|
||||||
$woocommerce->cart->get_item_data( $values ) .
|
<?php echo $woocommerce->cart->get_item_data( $cart_item ); ?>
|
||||||
'</td>
|
</td>
|
||||||
<td class="product-total">' . apply_filters( 'woocommerce_checkout_item_subtotal', $woocommerce->cart->get_product_subtotal( $_product, $values['quantity'] ), $values, $cart_item_key ) . '</td>
|
<td class="product-total">
|
||||||
</tr>';
|
<?php echo apply_filters( 'woocommerce_cart_item_subtotal', $woocommerce->cart->get_product_subtotal( $_product, $cart_item['quantity'] ), $cart_item, $cart_item_key ); ?>
|
||||||
endif;
|
</td>
|
||||||
endforeach;
|
</tr>
|
||||||
endif;
|
<?php
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
do_action( 'woocommerce_review_order_after_cart_contents' );
|
do_action( 'woocommerce_review_order_after_cart_contents' );
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -4,32 +4,30 @@
|
||||||
*
|
*
|
||||||
* @author WooThemes
|
* @author WooThemes
|
||||||
* @package WooCommerce/Templates/Emails
|
* @package WooCommerce/Templates/Emails
|
||||||
* @version 2.0.3
|
* @version 2.1.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||||
|
|
||||||
global $woocommerce;
|
global $woocommerce;
|
||||||
|
|
||||||
foreach ($items as $item) :
|
foreach ( $items as $item ) :
|
||||||
|
$_product = apply_filters( 'woocommerce_order_item_product', $order->get_product_from_item( $item ), $item );
|
||||||
// Get/prep product data
|
$item_meta = new WC_Order_Item_Meta( $item['item_meta'] );
|
||||||
$_product = $order->get_product_from_item( $item );
|
|
||||||
$item_meta = new WC_Order_Item_Meta( $item['item_meta'] );
|
|
||||||
$image = ($show_image) ? '<img src="'. current(wp_get_attachment_image_src( get_post_thumbnail_id( $_product->id ), 'thumbnail')) .'" alt="Product Image" height="'.$image_size[1].'" width="'.$image_size[0].'" style="vertical-align:middle; margin-right: 10px;" />' : '';
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<tr>
|
<tr>
|
||||||
<td style="text-align:left; vertical-align:middle; border: 1px solid #eee; word-wrap:break-word;"><?php
|
<td style="text-align:left; vertical-align:middle; border: 1px solid #eee; word-wrap:break-word;"><?php
|
||||||
|
|
||||||
// Show title/image etc
|
// Show title/image etc
|
||||||
echo apply_filters( 'woocommerce_order_product_image', $image, $_product, $show_image);
|
if ( $show_image )
|
||||||
|
echo apply_filters( 'woocommerce_order_item_thumbnail', '<img src="' . current( wp_get_attachment_image_src( get_post_thumbnail_id( $_product->id ), 'thumbnail') ) .'" alt="Product Image" height="' . $image_size[1] . '" width="' . $image_size[0] . '" style="vertical-align:middle; margin-right: 10px;" />', $item );
|
||||||
|
|
||||||
// Product name
|
// Product name
|
||||||
echo apply_filters( 'woocommerce_order_product_title', $item['name'], $_product );
|
echo apply_filters( 'woocommerce_order_item_name', $item['name'], $item );
|
||||||
|
|
||||||
// SKU
|
// SKU
|
||||||
echo ($show_sku && $_product->get_sku()) ? ' (#' . $_product->get_sku() . ')' : '';
|
if ( $show_sku && $_product->get_sku() )
|
||||||
|
echo ' (#' . $_product->get_sku() . ')';
|
||||||
|
|
||||||
// File URLs
|
// File URLs
|
||||||
if ( $show_download_links && $_product->exists() && $_product->is_downloadable() ) {
|
if ( $show_download_links && $_product->exists() && $_product->is_downloadable() ) {
|
||||||
|
@ -44,7 +42,7 @@ foreach ($items as $item) :
|
||||||
$filename = woocommerce_get_filename_from_url( $file_url );
|
$filename = woocommerce_get_filename_from_url( $file_url );
|
||||||
|
|
||||||
if ( count( $download_file_urls ) > 1 ) {
|
if ( count( $download_file_urls ) > 1 ) {
|
||||||
echo sprintf( __('Download %d:', 'woocommerce' ), $i + 1 );
|
echo sprintf( __( 'Download %d:', 'woocommerce' ), $i + 1 );
|
||||||
} elseif ( $i == 0 )
|
} elseif ( $i == 0 )
|
||||||
echo __( 'Download:', 'woocommerce' );
|
echo __( 'Download:', 'woocommerce' );
|
||||||
|
|
||||||
|
@ -55,16 +53,17 @@ foreach ($items as $item) :
|
||||||
}
|
}
|
||||||
|
|
||||||
// Variation
|
// Variation
|
||||||
echo ($item_meta->meta) ? '<br/><small>' . nl2br( $item_meta->display( true, true ) ) . '</small>' : '';
|
if ( $item_meta->meta )
|
||||||
|
echo '<br/><small>' . nl2br( $item_meta->display( true, true ) ) . '</small>';
|
||||||
|
|
||||||
?></td>
|
?></td>
|
||||||
<td style="text-align:left; vertical-align:middle; border: 1px solid #eee;"><?php echo $item['qty'] ;?></td>
|
<td style="text-align:left; vertical-align:middle; border: 1px solid #eee;"><?php echo $item['qty'] ;?></td>
|
||||||
<td style="text-align:left; vertical-align:middle; border: 1px solid #eee;"><?php echo $order->get_formatted_line_subtotal( $item ); ?></td>
|
<td style="text-align:left; vertical-align:middle; border: 1px solid #eee;"><?php echo $order->get_formatted_line_subtotal( $item ); ?></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<?php if ($show_purchase_note && $purchase_note = get_post_meta( $_product->id, '_purchase_note', true)) : ?>
|
<?php if ( $show_purchase_note && $purchase_note = get_post_meta( $_product->id, '_purchase_note', true ) ) : ?>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="3" style="text-align:left; vertical-align:middle; border: 1px solid #eee;"><?php echo apply_filters('the_content', $purchase_note); ?></td>
|
<td colspan="3" style="text-align:left; vertical-align:middle; border: 1px solid #eee;"><?php echo apply_filters( 'the_content', $purchase_note ); ?></td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
*
|
*
|
||||||
* @author WooThemes
|
* @author WooThemes
|
||||||
* @package WooCommerce/Templates/Emails/Plain
|
* @package WooCommerce/Templates/Emails/Plain
|
||||||
* @version 2.0.0
|
* @version 2.1.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||||
|
@ -12,14 +12,15 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||||
global $woocommerce;
|
global $woocommerce;
|
||||||
|
|
||||||
foreach ( $items as $item ) :
|
foreach ( $items as $item ) :
|
||||||
|
$_product = apply_filters( 'woocommerce_order_item_product', $order->get_product_from_item( $item ), $item );
|
||||||
|
$item_meta = new WC_Order_Item_Meta( $item['item_meta'] );
|
||||||
|
|
||||||
// Get/prep product data
|
// Title
|
||||||
$_product = $order->get_product_from_item( $item );
|
echo apply_filters( 'woocommerce_order_item_name', $item['name'], $item );
|
||||||
$item_meta = new WC_Order_Item_Meta( $item['item_meta'] );
|
|
||||||
|
|
||||||
// Title, sku, qty, price
|
// SKU
|
||||||
echo apply_filters( 'woocommerce_order_product_title', $item['name'], $_product );
|
if ( $show_sku && $_product->get_sku() )
|
||||||
echo $show_sku && $_product->get_sku() ? ' (#' . $_product->get_sku() . ')' : '';
|
echo ' (#' . $_product->get_sku() . ')';
|
||||||
|
|
||||||
// Variation
|
// Variation
|
||||||
echo $item_meta->meta ? "\n" . nl2br( $item_meta->display( true, true ) ) : '';
|
echo $item_meta->meta ? "\n" . nl2br( $item_meta->display( true, true ) ) : '';
|
||||||
|
|
|
@ -35,51 +35,58 @@ $order = new WC_Order( $order_id );
|
||||||
</tfoot>
|
</tfoot>
|
||||||
<tbody>
|
<tbody>
|
||||||
<?php
|
<?php
|
||||||
if (sizeof($order->get_items())>0) {
|
if ( sizeof( $order->get_items() ) > 0 ) {
|
||||||
|
|
||||||
foreach($order->get_items() as $item) {
|
foreach( $order->get_items() as $item ) {
|
||||||
$_product = get_product( $item['variation_id'] ? $item['variation_id'] : $item['product_id'] );
|
$_product = apply_filters( 'woocommerce_order_item_product', $order->get_product_from_item( $item ), $item );
|
||||||
|
$item_meta = new WC_Order_Item_Meta( $item['item_meta'] );
|
||||||
|
|
||||||
echo '<tr class = "' . esc_attr( apply_filters( 'woocommerce_order_table_item_class', 'order_table_item', $item, $order ) ) . '">
|
?>
|
||||||
<td class="product-name">';
|
<tr class="<?php echo esc_attr( apply_filters( 'woocommerce_order_item_class', 'order_item', $item, $order ) ); ?>">
|
||||||
|
<td class="product-name">
|
||||||
|
<?php
|
||||||
|
if ( $_product && ! $_product->is_visible() )
|
||||||
|
echo apply_filters( 'woocommerce_order_item_name', $item['name'], $item );
|
||||||
|
else
|
||||||
|
echo apply_filters( 'woocommerce_order_item_name', sprintf( '<a href="%s">%s</a>', get_permalink( $item['product_id'] ), $item['name'] ), $item );
|
||||||
|
|
||||||
if ( $_product && ! $_product->is_visible() )
|
echo apply_filters( 'woocommerce_order_item_quantity', ' <strong class="product-quantity">' . sprintf( '× %s', $item['qty'] ) . '</strong>', $item );
|
||||||
echo apply_filters( 'woocommerce_order_table_product_title', $item['name'], $item );
|
|
||||||
else
|
|
||||||
echo apply_filters( 'woocommerce_order_table_product_title', sprintf( '<a href="%s">%s</a>', get_permalink( $item['product_id'] ), $item['name'] ), $item );
|
|
||||||
|
|
||||||
echo apply_filters( 'woocommerce_order_table_item_quantity', ' <strong class="product-quantity">× ' . $item['qty'] . '</strong>', $item );
|
$item_meta->display();
|
||||||
|
|
||||||
$item_meta = new WC_Order_Item_Meta( $item['item_meta'] );
|
if ( $_product && $_product->exists() && $_product->is_downloadable() && $order->is_download_permitted() ) {
|
||||||
$item_meta->display();
|
|
||||||
|
|
||||||
if ( $_product && $_product->exists() && $_product->is_downloadable() && $order->is_download_permitted() ) {
|
$download_file_urls = $order->get_downloadable_file_urls( $item['product_id'], $item['variation_id'], $item );
|
||||||
|
|
||||||
$download_file_urls = $order->get_downloadable_file_urls( $item['product_id'], $item['variation_id'], $item );
|
$i = 0;
|
||||||
|
$links = array();
|
||||||
|
|
||||||
$i = 0;
|
foreach ( $download_file_urls as $file_url => $download_file_url ) {
|
||||||
$links = array();
|
|
||||||
|
|
||||||
foreach ( $download_file_urls as $file_url => $download_file_url ) {
|
$filename = woocommerce_get_filename_from_url( $file_url );
|
||||||
|
|
||||||
$filename = woocommerce_get_filename_from_url( $file_url );
|
$links[] = '<small><a href="' . $download_file_url . '">' . sprintf( __( 'Download file%s', 'woocommerce' ), ( count( $download_file_urls ) > 1 ? ' ' . ( $i + 1 ) . ': ' : ': ' ) ) . $filename . '</a></small>';
|
||||||
|
|
||||||
$links[] = '<small><a href="' . $download_file_url . '">' . sprintf( __( 'Download file%s', 'woocommerce' ), ( count( $download_file_urls ) > 1 ? ' ' . ( $i + 1 ) . ': ' : ': ' ) ) . $filename . '</a></small>';
|
$i++;
|
||||||
|
}
|
||||||
|
|
||||||
$i++;
|
echo implode( '<br/>', $links );
|
||||||
}
|
}
|
||||||
|
?>
|
||||||
|
</td>
|
||||||
|
<td class="product-total">
|
||||||
|
<?php echo $order->get_formatted_line_subtotal( $item ); ?>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<?php
|
||||||
|
|
||||||
echo implode( '<br/>', $links );
|
if ( in_array( $order->status, array( 'processing', 'completed' ) ) && ( $purchase_note = get_post_meta( $_product->id, '_purchase_note', true ) ) ) {
|
||||||
|
?>
|
||||||
|
<tr class="product-purchase-note">
|
||||||
|
<td colspan="3"><?php echo apply_filters( 'the_content', $purchase_note ); ?></td>
|
||||||
|
</tr>
|
||||||
|
<?php
|
||||||
}
|
}
|
||||||
|
|
||||||
echo '</td><td class="product-total">' . $order->get_formatted_line_subtotal( $item ) . '</td></tr>';
|
|
||||||
|
|
||||||
// Show any purchase notes
|
|
||||||
if ($order->status=='completed' || $order->status=='processing') {
|
|
||||||
if ($purchase_note = get_post_meta( $_product->id, '_purchase_note', true))
|
|
||||||
echo '<tr class="product-purchase-note"><td colspan="3">' . apply_filters('the_content', $purchase_note) . '</td></tr>';
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue