title: Magento: tracking and debugging its PHP code
body: <p>So, I'm starting to take a crack at some Magento code. I'm trying to track down the code that calculate shipping on a shopping cart page. I'm looking at a file called <code>shipping.phtml</code> in <code>/your_theme/template/checkout/cart/</code>. </p>
  
  <p>Zipcode input box:</p>
  
  <pre><code>            &lt;li&gt;
                  &lt;label for="postcode"&lt;?php if ($this-&gt;isZipCodeRequired()) echo ' class="required"' ?&gt;&gt;&lt;?php if ($this-&gt;isZipCodeRequired()) echo '&lt;em&gt;*&lt;/em&gt;' ?&gt;&lt;?php echo $this-&gt;__('Zip/Postal Code') ?&gt;&lt;/label&gt;
                  &lt;input class="input-text validate-postcode&lt;?php if ($this-&gt;isZipCodeRequired()):?&gt; required-entry&lt;?php endif;?&gt;" type="text" id="postcode" name="estimate_postcode" value="&lt;?php echo $this-&gt;htmlEscape($this-&gt;getEstimatePostcode()) ?&gt;" /&gt;
              &lt;/li&gt;
  </code></pre>
  
  <p>Calculate shipping button:</p>
  
  <pre><code>        &lt;div class="buttons-set"&gt;
              &lt;button type="button" onclick="coShippingMethodForm.submit()" class="button"&gt;&lt;span&gt;&lt;span&gt;&lt;?php echo $this-&gt;__('Get a Quote') ?&gt;&lt;/span&gt;&lt;/span&gt;&lt;/button&gt;
          &lt;/div&gt;
  </code></pre>
  
  <p>Javascript:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  //&lt;![CDATA[
      var coShippingMethodForm = new VarienForm('shipping-zip-form');
      var countriesWithOptionalZip = &lt;?php echo $this-&gt;helper('directory')-&gt;getCountriesWithOptionalZip(true) ?&gt;;
  
      coShippingMethodForm.submit = function () {
          var country = $F('country');
          var optionalZip = false;
  
          for (i=0; i &lt; countriesWithOptionalZip.length; i++) {
              if (countriesWithOptionalZip[i] == country) {
                  optionalZip = true;
              }
          }
          if (optionalZip) {
              $('postcode').removeClassName('required-entry');
          }
          else {
              $('postcode').addClassName('required-entry');
          }
          return VarienForm.prototype.submit.bind(coShippingMethodForm)();
      }
  //]]&gt;
  &lt;/script&gt;
  </code></pre>
  
  <p>Now, I have no idea where it goes from here. Could somebody provide me some hints as to where this goes from here?</p>
  
  <p>EDIT:</p>
  
  <p>I should add that I'm looking for the code that takes in the weight of the item  and calculates the USPS shipping cost. I've read that a file named Usps.php is what calculate this rate, but I wasn't able to change how the cost is displayed on the site even with core file modifications, so I wanted to find out myself that is indeed the code that calculate the shipping rate.</p>