title: Extra cost for shipping method based on product categories
body: <p>I'm trying to add extra cost (with $multiplier) to user selected shipping method based on product category.</p>
  
  <p>So, I need to check if any of products in cart is on $product_category_id .
  And if so then I need to multiply selected shipping cost to $multiplier value.</p>
  
  <p>This $multiplier should be applied to total shipping cost calculated by shipping method (not to every item in cart).</p>
  
  <pre class="lang-php prettyprint-override"><code>add_filter( 'woocommerce_package_rates','overwrite_shipping_cost', 100, 2 );
  function overwrite_shipping_cost($rates, $package ) {
      global $woocommerce;
  
          if ( get_field( 'multiplier', 'option' ) ) :
              $multiplier = get_field( 'multiplier', 'option' );
          else :
              $multiplier = 1;
          endif;
  
          $product_category_id    = array( 86, 21, 47 ); 
          $product_cats_ids       = wc_get_product_term_ids( $product_id, 'product_cat' ); 
          $product_category_id_check = false;
  
          foreach( $products as $cart_item ){
              $product_id = $cart_item['product_id'];
          }
  
          foreach ( $product_category_id as $key =&gt; $value ) {
              if ( in_array( $value, $product_cats_ids ) ) { 
                  $product_category_id_check = true;
              }
          }
  
          if ( ! is_admin() &amp;&amp; $product_category_id_check ) {
                      // If Shiptor 1
                      if ( isset( $rates['shiptor-shiptor:14:delivery-point_shiptor_terminal'] )) {
                          $rates['shiptor-shiptor:14:delivery-point_shiptor_terminal']-&gt;cost = $rates['shiptor-shiptor:14:delivery-point_shiptor_terminal']-&gt;cost * $multiplier;
                      } 
  
                      // If Shiptor 2
                      if ( isset( $rates['shiptor-shiptor:14:to-door_shiptor_courier'] )) {
                          $rates['shiptor-shiptor:14:to-door_shiptor_courier']-&gt;cost = $rates['shiptor-shiptor:14:to-door_shiptor_courier']-&gt;cost * $multiplier;
                      }
  
                      //If anothee shipping method
                      if ( isset( $rates['rpaefw_post_calc:16'] )) {
                          $rates['rpaefw_post_calc:16']-&gt;cost = $rates['rpaefw_post_calc:16']-&gt;cost * $multiplier;
                      }
          }
  
  
      return $rates;
  }
  </code></pre>
  
  <p>No result after executing the code. No $multiplier is applied shipping methods I provide in code.</p>