title: How to add the Cart button on top of the page in Woocommerce?
body: <p>I am developing a site using Wordpress+Woocommerce</p>
  
  <p>I am having a problem here, how to add the cart on top of the page that will dynamically change the number of products and price, each time a user adds a product to cart?</p>
  
  <p>Currently I am trying with this code, but no luck yet:</p>
  
  <pre><code>add_filter('add_to_cart_fragments', 'woocommerce_header_add_to_cart_fragment');
  
  function woocommerce_header_add_to_cart_fragment( $fragments ) {
      global $woocommerce;
  
      ob_start();
  
      ?&gt;
      &lt;a class="cart-contents" href="&lt;?php echo $woocommerce-&gt;cart-&gt;get_cart_url(); ?&gt;" title="&lt;?php _e('View your shopping cart', 'woothemes'); ?&gt;"&gt;&lt;?php echo sprintf(_n('%d item', '%d items', $woocommerce-&gt;cart-&gt;cart_contents_count, 'woothemes'), $woocommerce-&gt;cart-&gt;cart_contents_count);?&gt; - &lt;?php echo $woocommerce-&gt;cart-&gt;get_cart_total(); ?&gt;&lt;/a&gt;
      &lt;?php
  
      $fragments['a.cart-contents'] = ob_get_clean();
  
      return $fragments;
  
  }
  </code></pre>