Skip to content

Commit

Permalink
Merge pull request #2 from AashikP/fixes-issue#1
Browse files Browse the repository at this point in the history
Fixed infinite loading on updating order
  • Loading branch information
AashikP authored Feb 2, 2022
2 parents 6d62af6 + 31fd26f commit 3db54b1
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions item-total-for-wc.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* Plugin Name: Item total for WooCommerce
* Description: Simple plugin to display Item total in the order details page.
* Version: 1.0.0
* Version: 1.0.1
* Author: AashikP
* Author URI: https://aashikp.com
* Text Domain: item-total-for-wc
Expand Down Expand Up @@ -41,18 +41,20 @@ function ap_display_item_total( $product ) {
if ( ! is_int( $thepostid ) ) {
$thepostid = $post->ID;
}
$order = wc_get_order( $thepostid );
$order_items = $order->get_items();
foreach ( $order->get_items() as $item_id => $item ) {
if ( $item['product_id'] === $product->id ) {
$price = $item['total_tax'] + $item['total'];
if ( ! wp_doing_ajax() ) {
$order = wc_get_order( $thepostid );
$order_items = $order->get_items();
foreach ( $order->get_items() as $item_id => $item ) {
if ( $item['product_id'] === $product->id ) {
$price = $item['total_tax'] + $item['total'];
}
}
$test = '<td class="item_total_cost">';
$test .= '<div class="view alignleft">';
$test .= wc_price( $price, array( 'currency' => $order->get_currency() ) );
$test .= '</span></div></td>';
echo $test;
}
$test = '<td class="item_total_cost">';
$test .= '<div class="view">';
$test .= wc_price( $price, array( 'currency' => $order->get_currency() ) );
$test .= '</span></div></td>';
echo $test;
}
add_action( 'woocommerce_admin_order_item_values', 'ap_display_item_total' );
}

0 comments on commit 3db54b1

Please sign in to comment.