Fix more notices

This commit is contained in:
Mike Jolley 2016-08-09 14:30:10 +01:00
parent 71afe5fdf7
commit 30b0045d8a
4 changed files with 37 additions and 64 deletions

View File

@ -364,7 +364,7 @@ abstract class WC_Abstract_Legacy_Order extends WC_Data {
* @param array $item
*/
public function display_item_meta( $item ) {
_deprecated_function( 'get_item_meta', '2.7', 'wc_display_item_meta' );
_deprecated_function( 'display_item_meta', '2.7', 'wc_display_item_meta' );
$product = $item->get_product();
$item_meta = new WC_Order_Item_Meta( $item, $product );
$item_meta->display();

View File

@ -10,49 +10,43 @@
* happen. When this occurs the version of the template file will be bumped and
* the readme will list any important changes.
*
* @see https://docs.woocommerce.com/document/template-structure/
* @see https://docs.woothemes.com/document/template-structure/
* @author WooThemes
* @package WooCommerce/Templates/Emails
* @version 2.1.2
* @version 2.7.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
exit;
}
foreach ( $items as $item_id => $item ) :
$_product = apply_filters( 'woocommerce_order_item_product', $order->get_product_from_item( $item ), $item );
$item_meta = new WC_Order_Item_Meta( $item, $_product );
if ( apply_filters( 'woocommerce_order_item_visible', true, $item ) ) {
$product = $item->get_product();
?>
<tr class="<?php echo esc_attr( apply_filters( 'woocommerce_order_item_class', 'order_item', $item, $order ) ); ?>">
<td class="td" style="text-align:left; vertical-align:middle; border: 1px solid #eee; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif; word-wrap:break-word;"><?php
// Show title/image etc
if ( $show_image ) {
echo apply_filters( 'woocommerce_order_item_thumbnail', '<div style="margin-bottom: 5px"><img src="' . ( $_product->get_image_id() ? current( wp_get_attachment_image_src( $_product->get_image_id(), 'thumbnail') ) : wc_placeholder_img_src() ) .'" alt="' . esc_attr__( 'Product Image', 'woocommerce' ) . '" height="' . esc_attr( $image_size[1] ) . '" width="' . esc_attr( $image_size[0] ) . '" style="vertical-align:middle; margin-right: 10px;" /></div>', $item );
echo apply_filters( 'woocommerce_order_item_thumbnail', '<div style="margin-bottom: 5px"><img src="' . ( $product->get_image_id() ? current( wp_get_attachment_image_src( $product->get_image_id(), 'thumbnail') ) : wc_placeholder_img_src() ) .'" alt="' . esc_attr__( 'Product Image', 'woocommerce' ) . '" height="' . esc_attr( $image_size[1] ) . '" width="' . esc_attr( $image_size[0] ) . '" style="vertical-align:middle; margin-right: 10px;" /></div>', $item );
}
// Product name
echo apply_filters( 'woocommerce_order_item_name', $item['name'], $item, false );
// SKU
if ( $show_sku && is_object( $_product ) && $_product->get_sku() ) {
echo ' (#' . $_product->get_sku() . ')';
if ( $show_sku && is_object( $product ) && $product->get_sku() ) {
echo ' (#' . $product->get_sku() . ')';
}
// allow other plugins to add additional product information here
do_action( 'woocommerce_order_item_meta_start', $item_id, $item, $order, $plain_text );
// Variation
if ( ! empty( $item_meta->meta ) ) {
echo '<br/><small>' . nl2br( $item_meta->display( true, true, '_', "\n" ) ) . '</small>';
}
wc_display_item_meta( $item );
// File URLs
if ( $show_download_links ) {
$order->display_item_downloads( $item );
wc_display_item_downloads( $item );
}
// allow other plugins to add additional product information here
@ -65,7 +59,7 @@ foreach ( $items as $item_id => $item ) :
<?php
}
if ( $show_purchase_note && is_object( $_product ) && ( $purchase_note = get_post_meta( $_product->id, '_purchase_note', true ) ) ) : ?>
if ( $show_purchase_note && is_object( $product ) && ( $purchase_note = get_post_meta( $product->id, '_purchase_note', true ) ) ) : ?>
<tr>
<td colspan="3" style="text-align:left; vertical-align:middle; border: 1px solid #eee; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif;"><?php echo wpautop( do_shortcode( wp_kses_post( $purchase_note ) ) ); ?></td>
</tr>

View File

@ -13,7 +13,7 @@
* @see https://docs.woocommerce.com/document/template-structure/
* @author WooThemes
* @package WooCommerce/Templates/Emails/Plain
* @version 2.1.2
* @version 2.7.0
*/
if ( ! defined( 'ABSPATH' ) ) {
@ -21,59 +21,38 @@ if ( ! defined( 'ABSPATH' ) ) {
}
foreach ( $items as $item_id => $item ) :
$_product = apply_filters( 'woocommerce_order_item_product', $order->get_product_from_item( $item ), $item );
$item_meta = new WC_Order_Item_Meta( $item, $_product );
if ( apply_filters( 'woocommerce_order_item_visible', true, $item ) ) {
// Title
echo apply_filters( 'woocommerce_order_item_name', $item['name'], $item, false );
// SKU
if ( $show_sku && $_product->get_sku() ) {
echo ' (#' . $_product->get_sku() . ')';
$product = $item->get_product();
echo apply_filters( 'woocommerce_order_item_name', $item->get_name(), $item, false );
if ( $show_sku && $product->get_sku() ) {
echo ' (#' . $product->get_sku() . ')';
}
echo ' X ' . apply_filters( 'woocommerce_email_order_item_quantity', $item['qty'], $item );
echo ' = ' . $order->get_formatted_line_subtotal( $item ) . "\n";
// allow other plugins to add additional product information here
do_action( 'woocommerce_order_item_meta_start', $item_id, $item, $order, $plain_text );
// Variation
echo ( $item_meta_content = $item_meta->display( true, true ) ) ? "\n" . $item_meta_content : '';
// Quantity
echo "\n" . sprintf( __( 'Quantity: %s', 'woocommerce' ), apply_filters( 'woocommerce_email_order_item_quantity', $item['qty'], $item ) );
// Cost
echo "\n" . sprintf( __( 'Cost: %s', 'woocommerce' ), $order->get_formatted_line_subtotal( $item ) );
// Download URLs
if ( $show_download_links && $_product->exists() && $_product->is_downloadable() ) {
$download_files = $order->get_item_downloads( $item );
$i = 0;
foreach ( $download_files as $download_id => $file ) {
$i++;
if ( count( $download_files ) > 1 ) {
$prefix = sprintf( __( 'Download %d', 'woocommerce' ), $i );
} elseif ( $i == 1 ) {
$prefix = __( 'Download', 'woocommerce' );
}
echo "\n" . $prefix . '(' . esc_html( $file['name'] ) . '): ' . esc_url( $file['download_url'] );
}
echo strip_tags( wc_display_item_meta( $item, array(
'before' => "\n- ",
'separator' => "\n- ",
'after' => "",
'echo' => false,
'autop' => false,
) ) );
if ( $show_download_links ) {
echo strip_tags( wc_display_item_downloads( $item, array(
'before' => "\n- ",
'separator' => "\n- ",
'after' => "",
'echo' => false,
'show_url' => true,
) ) );
}
// allow other plugins to add additional product information here
do_action( 'woocommerce_order_item_meta_end', $item_id, $item, $order, $plain_text );
}
// Note
if ( $show_purchase_note && ( $purchase_note = get_post_meta( $_product->id, '_purchase_note', true ) ) ) {
if ( $show_purchase_note && ( $purchase_note = get_post_meta( $product->id, '_purchase_note', true ) ) ) {
echo "\n" . do_shortcode( wp_kses_post( $purchase_note ) );
}
echo "\n\n";
endforeach;

View File

@ -13,7 +13,7 @@
* @see https://docs.woocommerce.com/document/template-structure/
* @author WooThemes
* @package WooCommerce/Templates
* @version 2.5.0
* @version 2.7.0
*/
if ( ! defined( 'ABSPATH' ) ) {
@ -35,8 +35,8 @@ if ( ! apply_filters( 'woocommerce_order_item_visible', true, $item ) ) {
do_action( 'woocommerce_order_item_meta_start', $item_id, $item, $order );
$order->display_item_meta( $item );
$order->display_item_downloads( $item );
wc_display_item_meta( $item );
wc_display_item_downloads( $item );
do_action( 'woocommerce_order_item_meta_end', $item_id, $item, $order );
?>