Gravity Forms Coupons Add-On - can discount applied to particular products, not basket

Is there any way at all we can apply a 10% discount to a particular array of product fields, rather than the checkout total?

ChatGPT seems to think it can work using this filter, but it does not seem to affect anything.

add_filter( 'gform_coupons_discount_amount', function( $discount_amount, $coupon, $form, $entry ) {
    // Check that it's the specific coupon
    if ( strtolower($coupon['code']) === 'TOM10' ) { // <-- change to your coupon code (lowercase)
        
        $eligible_total = 0;
        $eligible_products = array( 48, 53, 54, 55 ); // <-- change to your field IDs

        foreach ( $form['fields'] as $field ) {
            if ( $field->type === 'product' ) {
                $field_id = (string) $field->id;
                $product_price = rgar( $entry, $field_id );
                
                if ( in_array( $field->id, $eligible_products ) && is_numeric( $product_price ) ) {
                    $eligible_total += floatval( $product_price );
                }
            }
        }

        // New discount: 10% of eligible products
        $discount_amount = $eligible_total * 0.10;

        // Debugging: log the result
        error_log( "Coupon applied: Eligible total = {$eligible_total}, Discount = {$discount_amount}" );
    }

    return $discount_amount;
}, 10, 4 );

Hi Theo,

This is possible with the Discount field of our GP eCommerce Fields Perk. Aside from the default of applying the discount to the form total, it also has the option to apply the discount to specific product fields, which should work for your use case. Please check out the documentation for more details on this.