Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
snippets:shipping:handling_fee_on_orders_under_100_dollar [2011/05/27 20:27] – [Data entry] sami.fiazsnippets:shipping:handling_fee_on_orders_under_100_dollar [2017/04/26 07:02] (current) – external edit 127.0.0.1
Line 4: Line 4:
 name          : Handling fee on orders under $100, free if over, live rates included. #the name of the snippet name          : Handling fee on orders under $100, free if over, live rates included. #the name of the snippet
 description   :  #description about snippet description   :  #description about snippet
-versions_tags :  #compatible versions+versions_tags : 0.6.0, 0.7.0, 0.7.1, 0.7.2, 1.0 #compatible versions
 reference_url : http://forum.foxycart.com/comments.php?DiscussionID=2898&page=1 #Comment_19695            # External link reference_url : http://forum.foxycart.com/comments.php?DiscussionID=2898&page=1 #Comment_19695            # External link
 tags_tags     : snippets, shipping, advance #tags, separated by commas. tags_tags     : snippets, shipping, advance #tags, separated by commas.
Line 10: Line 10:
 ---- ----
  
-===== Handling fee on orders under $100, free if over, live rates included.  =====+====== Handling fee on orders under $100, free if over, live rates included. ======
  
-TEXT GOES HERE!!!+<WRAP center round important 80%> 
 +**Using version 2.0?** There is a new snippet available for our latest version, [[v:2.0:snippets:live_rate_shipping_modification|available from here]]. 
 +</WRAP> 
 +This javascript allows you to add different amounts to shipping costs based on the carrier that the customer has chosen. This particular setup also provides free shipping if the order is over a certain price.
  
 +===== Step 1: Javascript =====
  
 +Paste the following right before the closing ''</head>'' tag in your **checkout template**. You'll need to edit the script to show the values you want to add for each carrier.
 +
 +<code javascript>
 +<script type="text/javascript">
 +function updateMyShippingCost() {
 +  // Grab current shipping cost (from live rates)
 +  var shippingCost = FC.checkout.config.orderShipping;
 +  
 +  // Grab currently selected shipping option
 +  var carrier = $("input[name=shipping_service]:checked").siblings(".fc_shipping_carrier").html();
 +  if ( carrier != null ) { // something is selected
 +    if ( carrier == "FedEx" ) { // it's FedEx!
 +      shippingCost += 10;
 +    } else if ( carrier == "UPS" ) { // it's UPS!
 +      shippingCost += 3.5;
 +      if (fc_json.total_price >= 100) { // Free shipping!
 +        shippingCost = 0;
 +      }
 +    }
 +  }
 +  // Update the shipping cost with the updated figures
 +  FC.checkout.config.orderShipping = shippingCost;
 +}
 +
 +jQuery(document).ready(function(){
 +  // set the custom function to run before the updatePriceDisplay function
 +  FC.checkout.overload("updatePriceDisplay", "updateMyShippingCost", null);
 +});
 +</script>
 +</code>
 ===== Related Forum Discussions ===== ===== Related Forum Discussions =====
  
   * http://forum.foxycart.com/comments.php?DiscussionID=2898&page=1#Comment_19695   * http://forum.foxycart.com/comments.php?DiscussionID=2898&page=1#Comment_19695

Site Tools