title: Select woocommerce chosen shipping method price
body: <p>I'm trying to select the chosen_shipping_method price in woocommerce using this code:</p>
  
  <pre><code>$packages = WC()-&gt;shipping-&gt;get_packages();
  foreach ($packages as $i =&gt; $package) {
      $chosen_method = isset(WC()-&gt;session-&gt;chosen_shipping_methods[$i]) ? WC()-&gt;session-&gt;chosen_shipping_methods[$i] : '';
  }
  echo $chosen_method;
  </code></pre>
  
  <p>the code works, but it prints the ID, and i cannot figure out how to make it print out the price.</p>
  
  <p>Here's package structure:</p>
  
  <p><img src="https://i.stack.imgur.com/XgrVL.png" alt="enter image description here"></p>
  
  <p>What i get with my code is <code>table_rate_shipping_shipping_self_install</code>, but what i need is the cost for the selected element, and not the id.</p>
  
  <p>i tried to change the code like this:</p>
  
  <pre><code>foreach ($packages as $i =&gt; $package['rates']) {
      $chosen_method = isset(WC()-&gt;session-&gt;chosen_shipping_methods[$i]) ? WC()-&gt;session-&gt;chosen_shipping_methods[$i] : '';
  }
  </code></pre>
  
  <p>But it printed out the id, same as before.</p>
  
  <p>Any ideas? sorry i'm a bit new to php.
  Thanks in advance</p>