Apply Coupon to the same product ID in 2 different ways

I installed a WooCommerce Smart Bundle plugin in my WooCommerce admin that enables me add a group of products under one product name as a bundle. My Add to Cart button is programmed in such a way that when I click on it, it adds the individual bundle products and their discount prices to the shopping cart.

The main problem I have is, how can I apply a coupon to the same product that appears twice in my shopping cart in two different ways depending on if the cart has some specific custom meta data?

Case in point, I currently have a scenario where a bundle product (made up of two products) when added, puts two product items into the cart. But then, the user can decide to separately add a third product (which is one of the bundle product items) to the cart that gives you 3 items in total, with 2 of the products being the exact same but with different prices

This is what I have so far (this logic, removes all discounts from applying to bundle products, but at the same time prevents individual products who have no meta data to not have discounts applied, which I am trying to prevent):

function exclude_bundle_products( $valid, $product, $coupon, $values ) {
    foreach ( WC()->cart->get_cart() as $cart_item ) {
        if ( $product->get_id() === $cart_item['data']->get_id() ) {
            if ( isset( $cart_item['custom_data']['new_price'] ) && ! empty( $cart_item['custom_data']['new_price'] )  ) {
                $valid = false;
    return $valid;
add_filter( 'woocommerce_coupon_is_valid_for_product', 'exclude_bundle_products', 9999, 4 );
How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum