WC_Order_Data_Store_CPT::get_total_tax_refunded()
Get the total tax refunded.
Method of the class: WC_Order_Data_Store_CPT{}
No Hooks.
Return
float
.
Usage
$WC_Order_Data_Store_CPT = new WC_Order_Data_Store_CPT(); $WC_Order_Data_Store_CPT->get_total_tax_refunded( $order );
- $order(WC_Order) (required)
- Order object.
WC_Order_Data_Store_CPT::get_total_tax_refunded() WC Order Data Store CPT::get total tax refunded code WC 9.4.2
public function get_total_tax_refunded( $order ) { 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 = 'tax' ) WHERE order_itemmeta.order_item_id = order_items.order_item_id AND order_itemmeta.meta_key IN ('tax_amount', 'shipping_tax_amount')", $order->get_id() ) ) ?? 0; return abs( $total ); }