Merge pull request #30957 from drjamesj/fix/30400_double_negative_refund_values

Fixes #30400 by multiplying refund values by -1
This commit is contained in:
Barry Hughes 2021-10-21 09:43:24 -07:00 committed by GitHub
commit c6bdff0d59
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 14 deletions

View File

@ -35,8 +35,8 @@ if ( ! defined( 'ABSPATH' ) ) {
<?php
echo wc_price( $item->get_total(), array( 'currency' => $order->get_currency() ) );
if ( $refunded = $order->get_total_refunded_for_item( $item_id, 'fee' ) ) {
echo '<small class="refunded">-' . wc_price( $refunded, array( 'currency' => $order->get_currency() ) ) . '</small>';
if ( $refunded = -1 * $order->get_total_refunded_for_item( $item_id, 'fee' ) ) {
echo '<small class="refunded">' . wc_price( $refunded, array( 'currency' => $order->get_currency() ) ) . '</small>';
}
?>
</div>
@ -59,8 +59,8 @@ if ( ! defined( 'ABSPATH' ) ) {
<?php
echo ( '' !== $tax_item_total ) ? wc_price( wc_round_tax_total( $tax_item_total ), array( 'currency' => $order->get_currency() ) ) : '&ndash;';
if ( $refunded = $order->get_tax_refunded_for_item( $item_id, $tax_item_id, 'fee' ) ) {
echo '<small class="refunded">-' . wc_price( $refunded, array( 'currency' => $order->get_currency() ) ) . '</small>';
if ( $refunded = -1 * $order->get_tax_refunded_for_item( $item_id, $tax_item_id, 'fee' ) ) {
echo '<small class="refunded">' . wc_price( $refunded, array( 'currency' => $order->get_currency() ) ) . '</small>';
}
?>
</div>

View File

@ -59,10 +59,10 @@ $row_class = apply_filters( 'woocommerce_admin_html_order_item_class', ! empt
<?php
echo '<small class="times">&times;</small> ' . esc_html( $item->get_quantity() );
$refunded_qty = $order->get_qty_refunded_for_item( $item_id );
$refunded_qty = -1 * $order->get_qty_refunded_for_item( $item_id );
if ( $refunded_qty ) {
echo '<small class="refunded">-' . esc_html( $refunded_qty * -1 ) . '</small>';
echo '<small class="refunded">' . esc_html( $refunded_qty * -1 ) . '</small>';
}
?>
</div>
@ -108,10 +108,10 @@ $row_class = apply_filters( 'woocommerce_admin_html_order_item_class', ! empt
echo '<span class="wc-order-item-discount">' . sprintf( esc_html__( '%s discount', 'woocommerce' ), wc_price( wc_format_decimal( $item->get_subtotal() - $item->get_total(), '' ), array( 'currency' => $order->get_currency() ) ) ) . '</span>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
$refunded = $order->get_total_refunded_for_item( $item_id );
$refunded = -1 * $order->get_total_refunded_for_item( $item_id );
if ( $refunded ) {
echo '<small class="refunded">-' . wc_price( $refunded, array( 'currency' => $order->get_currency() ) ) . '</small>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
echo '<small class="refunded">' . wc_price( $refunded, array( 'currency' => $order->get_currency() ) ) . '</small>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
?>
</div>
@ -156,10 +156,10 @@ $row_class = apply_filters( 'woocommerce_admin_html_order_item_class', ! empt
echo '&ndash;';
}
$refunded = $order->get_tax_refunded_for_item( $item_id, $tax_item_id );
$refunded = -1 * $order->get_tax_refunded_for_item( $item_id, $tax_item_id );
if ( $refunded ) {
echo '<small class="refunded">-' . wc_price( $refunded, array( 'currency' => $order->get_currency() ) ) . '</small>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
echo '<small class="refunded">' . wc_price( $refunded, array( 'currency' => $order->get_currency() ) ) . '</small>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
?>
</div>

View File

@ -64,9 +64,9 @@ if ( ! defined( 'ABSPATH' ) ) {
<div class="view">
<?php
echo wp_kses_post( wc_price( $item->get_total(), array( 'currency' => $order->get_currency() ) ) );
$refunded = $order->get_total_refunded_for_item( $item_id, 'shipping' );
$refunded = -1 * $order->get_total_refunded_for_item( $item_id, 'shipping' );
if ( $refunded ) {
echo wp_kses_post( '<small class="refunded">-' . wc_price( $refunded, array( 'currency' => $order->get_currency() ) ) . '</small>' );
echo wp_kses_post( '<small class="refunded">' . wc_price( $refunded, array( 'currency' => $order->get_currency() ) ) . '</small>' );
}
?>
</div>
@ -89,9 +89,9 @@ if ( ! defined( 'ABSPATH' ) ) {
<div class="view">
<?php
echo wp_kses_post( ( '' !== $tax_item_total ) ? wc_price( $tax_item_total, array( 'currency' => $order->get_currency() ) ) : '&ndash;' );
$refunded = $order->get_tax_refunded_for_item( $item_id, $tax_item_id, 'shipping' );
$refunded = -1 * $order->get_tax_refunded_for_item( $item_id, $tax_item_id, 'shipping' );
if ( $refunded ) {
echo wp_kses_post( '<small class="refunded">-' . wc_price( $refunded, array( 'currency' => $order->get_currency() ) ) . '</small>' );
echo wp_kses_post( '<small class="refunded">' . wc_price( $refunded, array( 'currency' => $order->get_currency() ) ) . '</small>' );
}
?>
</div>