The problem is that browsers won't reload a page when the user clicks on a link that begins with a named anchor (ie. <a href="#cart">). So no interaction with your query string ever occurs anywhere - either locally or on the server. You could try:
<a href="<?php echo($_SERVER[PHP_SELF]); ?>?product_name=MyProduct">
which would reload the page from the server with a proper query string, but I don't think you can mix a query string with a named anchor - at least not reliably across browsers.