WooCommerce - unset "<product> removed notice…" on cart page



PHP Snippet 1:

$notices = WC()->session->get('wc_notices', array());
foreach( $notices['notice'] as $key => &$notice){
    if( strpos( $notice, 'whilst' ) !== false){ 
        $BadNotice_key = $key;
        unset( $notices['notice'][$BadNotice_key] );
        WC()->session->set('wc_notices', $notices);
        break;
    }
}

PHP Snippet 2:

<?php foreach ( $notices as $notice ) :
        if ( strpos( $notice['notice'], 'removed' ) === false ) : ?>
        <div class="woocommerce-message"<?php echo wc_get_notice_data_attr( $notice ); ?> role="alert">
            <?php echo wc_kses_notice( $notice['notice'] ); ?>
        </div>
        <?php endif;
    endforeach; ?>

PHP Snippet 3:

// This line is to be added in the functions.php
add_filter('woocommerce_cart_item_removed_notice_type', '__return_null');