title: Add discount to shopping-cart using checkboxes
body: <p>I really need someone who can help me :-)</p>
  
  <p>I want to give customers a discount by clicking various checkboxes in my shop.</p>
  
  <p>Visitors can choose max 4 checkboxes. not 5, 6 etc. Is it possible to do this?</p>
  
  <p>My problem now is that the customer can actually get the item for free - or worse - I have to pay to sell goods to them!</p>
  
  <p>Here is the test-code:</p>
  
  <pre><code>    &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"&gt;&lt;/script&gt;
  &lt;input type="checkbox" name="checkbox1" id="checkbox1" class="css-checkbox" value="20" /&gt;
  &lt;label for="checkbox1" class="css-label"&gt;banana&lt;/label&gt;&lt;br&gt;
  
  &lt;input type="checkbox" name="checkbox2" id="checkbox2" class="css-checkbox" value="20" /&gt;
  &lt;label for="checkbox2" class="css-label"&gt;apple&lt;/label&gt;&lt;br&gt;
  
  &lt;input type="checkbox" name="checkbox3" id="checkbox3" class="css-checkbox" value="20" /&gt;
  &lt;label for="checkbox3" class="css-label"&gt;biscuit&lt;/label&gt;&lt;br&gt;
  
  &lt;input type="checkbox" name="checkbox4" id="checkbox4" class="css-checkbox" value="20" /&gt;
  &lt;label for="checkbox4" class="css-label"&gt;jam &lt;/label&gt;&lt;br&gt;
  
  &lt;input type="checkbox" name="checkbox5" id="checkbox5" class="css-checkbox" value="20" /&gt;
  &lt;label for="checkbox5" class="css-label"&gt;orange &lt;/label&gt;&lt;br&gt;
  
  &lt;input type="checkbox" name="checkbox6" id="checkbox6" class="css-checkbox" value="20" /&gt;
  &lt;label for="checkbox6" class="css-label"&gt;pinepple &lt;/label&gt;&lt;br&gt;
  
  &lt;br /&gt;&lt;br /&gt;
  
  &lt;span id="total"&gt;&lt;b&gt;Normal price: &lt;/b&gt; 100&lt;/span&gt;&lt;/p&gt;
  
  &lt;script&gt;
  var $total = 100;
  var $total2 = 100;
  
  $('input:checkbox').on('change', function() {
      if (this.checked)
          $total += -this.value;
      else
          $total -= -this.value;
  
          if ($total2 &gt; $total)
              $('#total').html('&lt;b&gt;Discount  price: &lt;/b&gt;'+$total);
          else
              $('#total').html('&lt;b&gt;Normal price: &lt;/b&gt;'+$total);
  });
  &lt;/script&gt;
  </code></pre>