jQuery get values of 4th and greater number of checkboxes clicked using an each loop
<p>I am running an each loop to a form, to sum values based on user selections and get the final price of a product.
The hard part is that in specific checkbox groups I have further restrictions like: the group A will start adding to the price, after 4 and more checkboxes are clicked and only add the values of those clicked after the 3rd item.</p>

<p>Below is the function that I ve created and I am searching of a solution to my problem:</p>

<pre><code>var quantity = 1;
var removedProductPrice = false; //User can pick a variation of the same product, so the price changes to that selected variation (flag)    
var product_price = parseFloat($("#product").val()); //Base product price
var totalProduct = product_price;

$(":input", "#productForm").each(function(){
    if(this.type == 'checkbox' || this.type == 'radio'){
        if(this.checked == true){

            priceProtocol = $(this).attr('rel').split('_');
            //priceProtocol[0]: 'variation/component/steady, priceProtocol[1]: number of choices

            switch(priceProtocol[0]){               
                case 'variation':
                    removedProductPrice = true;
                    totalProduct = Number(totalProduct)+Number(this.value);
                break;

                case 'component':                       
                    totalProduct = Number(totalProduct)+Number(this.value);                     
                break;          

                case 'steady':                      
                    //If the number of clicked checkboxes is greater than the limit, start adding to the price
                    if($("input[name='"+this.name+"']:checked").length &gt; priceProtocol[1]){                         
                        totalProduct = Number(totalProduct)+Number(caller.val());
                    }
                break;  
            }

        }
    }else if(this.id == 'product_quantity'){ quantity  = this.value; }
});

//If a variation selected, change the price to that of the variation
if(removedProductPrice){ totalProduct = totalProduct-product_price; }

//Multiple by the selected quantity
totalProduct = Number(quantity)*totalProduct;

    //Preview the final price
$("#current_product_price").html(totalProduct.toFixed(2));  
 }
</code></pre>

<p>How can I achieve that described above?</p>
