Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(woocommerce-emails): use the default email if there are no donation products #3545

Merged
merged 3 commits into from
Nov 21, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: better way to do it
adekbadek committed Nov 14, 2024

Verified

This commit was signed with the committer’s verified signature.
adekbadek Adam Cassis
commit b3e62f020de78e416dd5efaa905a7c2ee6ee09bb
Original file line number Diff line number Diff line change
@@ -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;
}