Require Coupon For Checkout To Proceed

// Force requirement that a coupon is required to complete checkout.
// create coupon called "coupon" then add new category to any product called "coupon"
add_action( 'woocommerce_checkout_process', 'lf_force_coupon_validation' );

// validate coupon
function lf_force_coupon_validation(){
    // Set $cat_in_cart to false
    $cat_in_cart = false;
     
    // Loop through all products in the Cart        
    foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
     
        // If Cart has category "coupon", set $cat_in_cart to true
        if ( has_term( 'coupon', 'product_cat', $cart_item['product_id'] ) ) {
            $cat_in_cart = true;
            break;
        }
    }
       
    // Do something if category "coupon" is in the Cart      
    if ( $cat_in_cart ) {


        $wc = WC();
        $coupons = $wc->cart->get_coupons();

        if(empty($coupons)){
            $errornotice = __( 'Coupon is a required field. Please enter a coupon.', 'lf' );

            wc_add_notice( $errornotice , 'error' );
        }
    }
 
}
Description:

If any product is in checkout with “coupon” category enabled, the buyer will be required to use a coupon (that you create in WooCommerce) called “coupon” to be added to coupon component in order for checkout to proceed.