Skip to content

Commit

Permalink
Show refunded items in customer facing screens
Browse files Browse the repository at this point in the history
  • Loading branch information
mikejolley committed Mar 15, 2019
1 parent 9b9e315 commit 6329f61
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 15 deletions.
2 changes: 1 addition & 1 deletion assets/css/woocommerce-rtl.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/css/woocommerce.css

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions assets/css/woocommerce.scss
Original file line number Diff line number Diff line change
Expand Up @@ -1101,6 +1101,10 @@ p.demo_store,
small {
font-weight: normal;
}

del {
font-weight: normal;
}
}

tbody:first-child tr:first-child {
Expand Down
12 changes: 11 additions & 1 deletion templates/emails/email-order-items.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,17 @@
?>
</td>
<td class="td" style="text-align:<?php echo esc_attr( $text_align ); ?>; vertical-align:middle; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif;">
<?php echo wp_kses_post( apply_filters( 'woocommerce_email_order_item_quantity', $item->get_quantity(), $item ) ); ?>
<?php
$qty = $item->get_quantity();
$refunded_qty = $order->get_qty_refunded_for_item( $item_id );

if ( $refunded_qty ) {
$qty_display = '<del>' . esc_html( $qty ) . '</del> <ins>' . esc_html( $qty - ( $refunded_qty * -1 ) ) . '</ins>';
} else {
$qty_display = esc_html( $qty );
}
echo wp_kses_post( apply_filters( 'woocommerce_email_order_item_quantity', $qty_display, $item ) );
?>
</td>
<td class="td" style="text-align:<?php echo esc_attr( $text_align ); ?>; vertical-align:middle; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif;">
<?php echo wp_kses_post( $order->get_formatted_line_subtotal( $item ) ); ?>
Expand Down
2 changes: 1 addition & 1 deletion templates/myaccount/orders.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<tbody>
<?php foreach ( $customer_orders->orders as $customer_order ) :
$order = wc_get_order( $customer_order );
$item_count = $order->get_item_count();
$item_count = $order->get_item_count() - $order->get_item_count_refunded();
?>
<tr class="woocommerce-orders-table__row woocommerce-orders-table__row--status-<?php echo esc_attr( $order->get_status() ); ?> order">
<?php foreach ( wc_get_account_orders_columns() as $column_id => $column_name ) : ?>
Expand Down
32 changes: 21 additions & 11 deletions templates/order/order-details-item.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
* 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.woocommerce.com/document/template-structure/
* @package WooCommerce/Templates
* @version 3.0.0
* @version 3.6.0
*/

if ( ! defined( 'ABSPATH' ) ) {
Expand All @@ -27,22 +27,32 @@

<td class="woocommerce-table__product-name product-name">
<?php
$is_visible = $product && $product->is_visible();
$product_permalink = apply_filters( 'woocommerce_order_item_permalink', $is_visible ? $product->get_permalink( $item ) : '', $item, $order );
$is_visible = $product && $product->is_visible();
$product_permalink = apply_filters( 'woocommerce_order_item_permalink', $is_visible ? $product->get_permalink( $item ) : '', $item, $order );

echo apply_filters( 'woocommerce_order_item_name', $product_permalink ? sprintf( '<a href="%s">%s</a>', $product_permalink, $item->get_name() ) : $item->get_name(), $item, $is_visible );
echo apply_filters( 'woocommerce_order_item_quantity_html', ' <strong class="product-quantity">' . sprintf( '&times; %s', $item->get_quantity() ) . '</strong>', $item );
echo apply_filters( 'woocommerce_order_item_name', $product_permalink ? sprintf( '<a href="%s">%s</a>', $product_permalink, $item->get_name() ) : $item->get_name(), $item, $is_visible ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped

do_action( 'woocommerce_order_item_meta_start', $item_id, $item, $order, false );
$qty = $item->get_quantity();
$refunded_qty = $order->get_qty_refunded_for_item( $item_id );

wc_display_item_meta( $item );
if ( $refunded_qty ) {
$qty_display = '<del>' . esc_html( $qty ) . '</del> <ins>' . esc_html( $qty - ( $refunded_qty * -1 ) ) . '</ins>';
} else {
$qty_display = esc_html( $qty );
}

do_action( 'woocommerce_order_item_meta_end', $item_id, $item, $order, false );
echo apply_filters( 'woocommerce_order_item_quantity_html', ' <strong class="product-quantity">' . sprintf( '&times; %s', $qty_display ) . '</strong>', $item ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped

do_action( 'woocommerce_order_item_meta_start', $item_id, $item, $order, false );

wc_display_item_meta( $item ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped

do_action( 'woocommerce_order_item_meta_end', $item_id, $item, $order, false );
?>
</td>

<td class="woocommerce-table__product-total product-total">
<?php echo $order->get_formatted_line_subtotal( $item ); ?>
<?php echo $order->get_formatted_line_subtotal( $item ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
</td>

</tr>
Expand All @@ -51,7 +61,7 @@

<tr class="woocommerce-table__product-purchase-note product-purchase-note">

<td colspan="2"><?php echo wpautop( do_shortcode( wp_kses_post( $purchase_note ) ) ); ?></td>
<td colspan="2"><?php echo wpautop( do_shortcode( wp_kses_post( $purchase_note ) ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></td>

</tr>

Expand Down

0 comments on commit 6329f61

Please sign in to comment.