/** * Ask for donation in checkout process */ add_action( 'woocommerce_review_order_before_submit', 'cc_checkout_donation', 9999 ); function cc_checkout_donation() { $product_ids = array(223, 224, 225); // IDs for products created for each of the donation amounts eg $2, $5 and $10 $in_cart = false; foreach(WC()->cart->get_cart() as $cart_item) { $product_in_cart = $cart_item['product_id']; if (in_array( $product_in_cart, $product_ids)) { $in_cart = true; break; } } if (! $in_cart) { echo '