From 31fd26fbfa18cd9e76ee03a47d4b96e7f412be8b Mon Sep 17 00:00:00 2001 From: AashikP <17475174+AashikP@users.noreply.github.com> Date: Wed, 2 Feb 2022 18:51:37 +0530 Subject: [PATCH] Fixed infinite loading on updating order Fixes issue#1 --- item-total-for-wc.php | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/item-total-for-wc.php b/item-total-for-wc.php index 8066c9d..ff9bbf7 100644 --- a/item-total-for-wc.php +++ b/item-total-for-wc.php @@ -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 @@ -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 = '