parent
6760589381
commit
b9708c4df9
|
@ -148,7 +148,15 @@ if ( wc_tax_enabled() ) {
|
|||
|
||||
<tr>
|
||||
<td class="label"><?php _e( 'Shipping', 'woocommerce' ); ?> <span class="tips" data-tip="<?php _e( 'This is the shipping and handling total costs for the order.', 'woocommerce' ); ?>">[?]</span>:</td>
|
||||
<td class="total"><?php echo wc_price( $order->get_total_shipping(), array( 'currency' => $order->get_order_currency() ) ); ?></td>
|
||||
<td class="total"><?php
|
||||
if ( ( $refunded = $order->get_total_shipping_refunded() ) > 0 ) {
|
||||
echo '<del>' . strip_tags( wc_price( $order->get_total_shipping(), array( 'currency' => $order->get_order_currency() ) ) ) . '</del> <ins>' . wc_price( $order->get_total_shipping() - $refunded, array( 'currency' => $order->get_order_currency() ) ) . '</ins>';
|
||||
} else {
|
||||
echo wc_price( $order->get_total_shipping(), array( 'currency' => $order->get_order_currency() ) );
|
||||
}
|
||||
|
||||
|
||||
?></td>
|
||||
<td width="1%"></td>
|
||||
</tr>
|
||||
|
||||
|
@ -158,7 +166,13 @@ if ( wc_tax_enabled() ) {
|
|||
<?php foreach ( $order->get_tax_totals() as $code => $tax ) : ?>
|
||||
<tr>
|
||||
<td class="label"><?php echo $tax->label; ?>:</td>
|
||||
<td class="total"><?php echo $tax->formatted_amount; ?></td>
|
||||
<td class="total"><?php
|
||||
if ( ( $refunded = $order->get_total_tax_refunded_by_rate_id( $tax->rate_id ) ) > 0 ) {
|
||||
echo '<del>' . strip_tags( $tax->formatted_amount ) . '</del> <ins>' . wc_price( $tax->amount - $refunded, array( 'currency' => $order->get_order_currency() ) ) . '</ins>';
|
||||
} else {
|
||||
echo $tax->formatted_amount;
|
||||
}
|
||||
?></td>
|
||||
<td width="1%"></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
|
|
|
@ -79,6 +79,27 @@ class WC_Order extends WC_Abstract_Order {
|
|||
return abs( $total );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the total shipping refunded
|
||||
*
|
||||
* @since 2.4
|
||||
* @return float
|
||||
*/
|
||||
public function get_total_shipping_refunded() {
|
||||
global $wpdb;
|
||||
|
||||
$total = $wpdb->get_var( $wpdb->prepare( "
|
||||
SELECT SUM( order_itemmeta.meta_value )
|
||||
FROM {$wpdb->prefix}woocommerce_order_itemmeta AS order_itemmeta
|
||||
INNER JOIN $wpdb->posts AS posts ON ( posts.post_type = 'shop_order_refund' AND posts.post_parent = %d )
|
||||
INNER JOIN {$wpdb->prefix}woocommerce_order_items AS order_items ON ( order_items.order_id = posts.ID AND order_items.order_item_type = 'shipping' )
|
||||
WHERE order_itemmeta.order_item_id = order_items.order_item_id
|
||||
AND order_itemmeta.meta_key IN ('cost')
|
||||
", $this->id ) );
|
||||
|
||||
return abs( $total );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the refunded amount for a line item
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue