Magento 1.9 – How to Show Shipping and Handling Fee on Cart Total

cartmagento-1.9shippingshipping-methodstotals

I have only one shipping method – Table rate on which I calculate two different aspects.

  1. for over $200 – shipping price will be $0.00 that is free.
  2. below $200 is $9.50.

Now I get these calculation processed only after I trigger estimate shipping form or co-shipping form. Is that possible to load the shipping fee automatically once the page loads? and show up the result on cart total box.

Best Answer

I just send the co-shipping-method-form details via ajax submission on page load. this helped me to calculate the shipping Fee automatically without the estimate shipping and update total things. code what I used to trigger the form is below hope this will help someone.. also if this method is not good to use please guide me on this.

<script type="text/javascript">
        (function($){
            $(document).ready(function() {

                var currentRequest = null;
                var url = "<?php echo $this->getUrl('checkout/cart/estimateUpdatePost') ?>"; // co-shipping-method-form action url.
                var data = $("#co-shipping-method-form");
                $("#process").show(); // shows loading

                currentRequest =$.ajax({
                  type: "POST",
                  data: data.serialize(),
                  dataType: "html",
                  url: url,
                  beforeSend : function(){           
                        if(currentRequest != null){
                            currentRequest.abort();
                        }
                   },
                  success: function(response){ 
                      //console.log(response);
                      // find element with class name .cart-totals
                      var result = $('.cart-totals', response)

                      //console.log(result);
                      // replace with original
                      $(".cart-totals-wrapper").html(result); 

                      $("#process").hide("slow"); // hide loading
                   },
                  });    
                return false;    
            });
        })(jQuery);
    </script>
Related Topic