From 0f3be9fce47112d206b11d467db8934c1520d2c5 Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Wed, 6 Mar 2019 16:17:33 +0000 Subject: [PATCH] phpcs --- .../meta-boxes/views/html-order-item.php | 30 ++++++++++++------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/includes/admin/meta-boxes/views/html-order-item.php b/includes/admin/meta-boxes/views/html-order-item.php index f6c5e0b742b..2de0d8ae9c0 100644 --- a/includes/admin/meta-boxes/views/html-order-item.php +++ b/includes/admin/meta-boxes/views/html-order-item.php @@ -2,9 +2,11 @@ /** * Shows an order item * + * @package WooCommerce/Admin * @var object $item The item being displayed * @var int $item_id The id of the item being displayed */ + if ( ! defined( 'ABSPATH' ) ) { exit; } @@ -31,7 +33,7 @@ $row_class = apply_filters( 'woocommerce_admin_html_order_item_class', ! empt echo esc_html( $item->get_variation_id() ); } else { /* translators: %s: variation id */ - printf( esc_html__( '%s (No longer exists)', 'woocommerce' ), $item->get_variation_id() ); + printf( esc_html__( '%s (No longer exists)', 'woocommerce' ), esc_html( $item->get_variation_id() ) ); } echo ''; } @@ -49,7 +51,7 @@ $row_class = apply_filters( 'woocommerce_admin_html_order_item_class', ! empt
get_item_total( $item, false, true ), array( 'currency' => $order->get_currency() ) ); + echo wc_price( $order->get_item_total( $item, false, true ), array( 'currency' => $order->get_currency() ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped if ( $item->get_subtotal() !== $item->get_total() ) { echo '-' . wc_price( wc_format_decimal( $order->get_item_subtotal( $item, false, false ) - $order->get_item_total( $item, false, false ), '' ), array( 'currency' => $order->get_currency() ) ) . ''; @@ -60,10 +62,12 @@ $row_class = apply_filters( 'woocommerce_admin_html_order_item_class', ! empt
× ' . esc_html( $item->get_quantity() ); + echo '× ' . esc_html( $item->get_quantity() ); - if ( $refunded_qty = $order->get_qty_refunded_for_item( $item_id ) ) { - echo '-' . ( $refunded_qty * -1 ) . ''; + $refunded_qty = $order->get_qty_refunded_for_item( $item_id ); + + if ( $refunded_qty ) { + echo '-' . esc_html( $refunded_qty * -1 ) . ''; } ?>
@@ -77,7 +81,7 @@ $row_class = apply_filters( 'woocommerce_admin_html_order_item_class', ! empt
get_total(), array( 'currency' => $order->get_currency() ) ); + echo wc_price( $item->get_total(), array( 'currency' => $order->get_currency() ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped if ( $item->get_subtotal() !== $item->get_total() ) { echo '-' . wc_price( wc_format_decimal( $item->get_subtotal() - $item->get_total(), '' ), array( 'currency' => $order->get_currency() ) ) . ''; @@ -106,7 +110,9 @@ $row_class = apply_filters( 'woocommerce_admin_html_order_item_class', ! empt get_taxes() ) && wc_tax_enabled() ) { + $tax_data = wc_tax_enabled() ? $item->get_taxes() : false; + + if ( $tax_data ) { foreach ( $order_taxes as $tax_item ) { $tax_item_id = $tax_item->get_rate_id(); $tax_item_total = isset( $tax_data['total'][ $tax_item_id ] ) ? $tax_data['total'][ $tax_item_id ] : ''; @@ -116,7 +122,7 @@ $row_class = apply_filters( 'woocommerce_admin_html_order_item_class', ! empt
$order->get_currency() ) ); + echo wc_price( wc_round_tax_total( $tax_item_total ), array( 'currency' => $order->get_currency() ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } else { echo '–'; } @@ -125,12 +131,14 @@ $row_class = apply_filters( 'woocommerce_admin_html_order_item_class', ! empt if ( '' === $tax_item_total ) { echo ''; } else { - echo '-' . wc_price( wc_round_tax_total( $tax_item_subtotal - $tax_item_total ), array( 'currency' => $order->get_currency() ) ) . ''; + echo '-' . wc_price( wc_round_tax_total( $tax_item_subtotal - $tax_item_total ), array( 'currency' => $order->get_currency() ) ) . ''; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } } - if ( $refunded = $order->get_tax_refunded_for_item( $item_id, $tax_item_id ) ) { - echo '-' . wc_price( $refunded, array( 'currency' => $order->get_currency() ) ) . ''; + $refunded = $order->get_tax_refunded_for_item( $item_id, $tax_item_id ); + + if ( $refunded ) { + echo '-' . wc_price( $refunded, array( 'currency' => $order->get_currency() ) ) . ''; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } ?>