get_items( 'line_item' ); $amount_to_deduct = 0; /** @var \WC_Order_Item_Product $line_item */ foreach ( $line_items as $line_item ) { $product = $line_item->get_product(); if ( ! Product::is_gift_card( $product ) ) { continue; } $amount_to_deduct += $line_item->get_total(); } $order_data['net_total'] = $order_data['net_total'] - $amount_to_deduct; return $order_data; } }