title: Add a fee to WooCommerce per product, based on category
body: <p>I've been trying for a while now to get this working but I haven't find any solution that does exactly what we need, and I'm far from an expert in PHP so I'm a bit lost.</p>
  
  <p>We use WooCommerce and WooTickets. The goal is to add a 5% fee for "Service Fee" only to products in the "Tickets" category (ID:34).</p>
  
  <p>We have found this code snipper, that add a fixed cost based on a product category :</p>
  
  <pre><code>// Add Service Fee to Category
  function woo_add_cart_fee() {
  
  $category_ID = '23';
  global $woocommerce;
  
  foreach ($woocommerce-&gt;cart-&gt;cart_contents as $key =&gt; $values ) {
      // Get the terms, i.e. category list using the ID of the product
  $terms = get_the_terms( $values['product_id'], 'product_cat' );
      // Because a product can have multiple categories, we need to iterate through the list of the products category for a match
      foreach ($terms as $term) {
          // 23 is the ID of the category for which we want to remove the payment gateway
          if($term-&gt;term_id == $category_ID){
           $excost = 6;
           }
           }
          $woocommerce-&gt;cart-&gt;add_fee('Service Fee', $excost, $taxable = false, $tax_class = '');
  }
  }
  add_action( 'woocommerce_cart_calculate_fees', 'woo_add_cart_fee' );
  </code></pre>
  
  <p>The main problem with this solution is that it adds a fixed cost, whereas we need a percentage cost.</p>
  
  <p>We also found this code snippet from WooThemes themselves :</p>
  
  <pre><code>/**
   * Add a 1% surcharge to your cart / checkout
   * change the $percentage to set the surcharge to a value to suit
   * Uses the WooCommerce fees API
   *
   * Add to theme functions.php
   */
  add_action( 'woocommerce_cart_calculate_fees','woocommerce_custom_surcharge' );
  function woocommerce_custom_surcharge() {
    global $woocommerce;
  
      if ( is_admin() &amp;&amp; ! defined( 'DOING_AJAX' ) )
          return;
  
      $percentage = 0.05;
      $surcharge = ( $woocommerce-&gt;cart-&gt;cart_contents_total + $woocommerce-&gt;cart-&gt;shipping_total ) * $percentage;    
      $woocommerce-&gt;cart-&gt;add_fee( 'Service Fee', $surcharge, true, 'standard' );
  
  }
  </code></pre>
  
  <p>But once again, there are a few problems with this solution...</p>
  
  <p>1) The product category is not taken into consideration
  2) It adds a fee based on the entire cart value, but it should only add a 5% fee to products in the "Tickets" product category, not the entire cart</p>