From b3e62f020de78e416dd5efaa905a7c2ee6ee09bb Mon Sep 17 00:00:00 2001 From: Adam Cassis Date: Thu, 14 Nov 2024 10:09:45 +0100 Subject: [PATCH] feat: better way to do it --- .../woocommerce/class-woocommerce-connection.php | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/includes/reader-revenue/woocommerce/class-woocommerce-connection.php b/includes/reader-revenue/woocommerce/class-woocommerce-connection.php index 7f675afb55..5aa4033429 100644 --- a/includes/reader-revenue/woocommerce/class-woocommerce-connection.php +++ b/includes/reader-revenue/woocommerce/class-woocommerce-connection.php @@ -267,14 +267,7 @@ public static function force_disable_order_attribution( $should_allow ) { */ public static function send_customizable_receipt_email( $enable, $order, $class ) { // If there are no donation products in the order, do not override the default WC receipt email. - $has_donation_product = false; - $donation_product_ids = array_values( \Newspack\Donations::get_donation_product_child_products_ids() ); - foreach ( $order->get_items() as $item_id => $item ) { - if ( in_array( $item->get_product()->get_id(), $donation_product_ids ) ) { - $has_donation_product = true; - break; - } - } + $has_donation_product = \Newspack\Donations::get_order_donation_product_id( $order_id ) !== false; if ( ! $has_donation_product ) { return $enable; }