View Single Post
  #2  
Old 09-15-2007, 11:45 AM
 
joltedpixel joltedpixel is offline
 

Member
  
Join Date: Sep 2005
Posts: 25
 

Default Re: Free Ground Shipping Mod

Free Ground Shipping Mod

The purpose of this mod is to allow people to create a zone that offers free shipping but still keep the existing prices for other shipping options. Currently x-cart has a free shipping option but once selected it will change the price of all shipping methods to zero.




READ THIS:

* This is not the easiest mod to install and should be done by an intermediate - advanced user. I will do my best to make it as simple as possible.
* I have only tested this with X-Cart 4.1.8 M
* This is not fully tested so please test it in a dev site first. We are not responsible for any damages.




Some Pre-Reqs before getting started:
1) Create a shipping zone
2) Create a shipping charge for that particular zone (free one) our is called ⌠Free USPS/UPS Ground Shipping■ and is set to zero dollars for the US (lower 48 states) zone we created earlier.
3) X-Cart 4.1.8 (only one tested so far)
4) Get the shipping charge ID number this can be found by viewing the source on the shipping charges page. You should get a two digit number or three digit number that will be in the value of the radio button for that shipping charge. Mine was 167 and you can see that in the code later.
5) I have this installed http://forum.x-cart.com/showthread.php?t=8901 (use post 59) Not sure if needed or not. I have not tested without it installed. Please let me know when you test.


Step 1
Add this to cart.php

Code:
///////////////////////// ///////// ADDED ///////// ///////////////////////// //// JoltedPixel.com //// ///////////////////////// $free_ground_id = ▒167'; // <<<< SET THIS TO MATCH SHIPPING ZONE ID # FOR FREE SHIPPING /////// Assigns Smart Variables $free_ground = true; foreach ($cart[▓products▓] as $product) { // Runs through all products in Cart if ($product[▓free_shipping▓] != ▒G▓){ // Counts $free_ground = false; } } /////// If there is no free ground shipping it finds the correct radio button to check if ($free_ground == false){ foreach ($shipping as $s) { if ($previous == $free_ground_id){ $free_ground_id_next = $s["shippingid"]; } $previous = $s["shippingid"]; } } /////// Assigns Smart Variables $smarty->assign("free_ground", $free_ground); $smarty->assign("free_ground_id", $free_ground_id); $smarty->assign("free_ground_id_next", $free_ground_id_next); ///////////////////////////// //// END ADDED SECTION ////// /////////////////////////////

Should go around line 450 and right after this chunk of code:

Code:
} else { $cart["delivery"] = ""; $cart["shippingid"] = 0; }


Step 2
Replace these two lines in skin1/modules/Fast_Lane_Checkout/shipping_methods.tpl

Code:
<td width="5"><input type="radio" id="shippingid{$s.shippingid}" name="shippingid" value="{$s.shippingid}"{if $s.shippingid eq $cart.shippingid} checked="checked"{/if}{if $allow_cod} onclick="javascript: display_cod({if $s.is_cod eq ▒Y▓}true{else}false{/if});"{/if} /></td> <td><label for="shippingid{$s.shippingid}">{$s.shipping|trademark:$insert_trademark}{if $s.shipping_time ne ""} - {$s.shipping_time}{/if}{if $config.Appearance.display_shipping_cost eq "Y" and ($login ne "" or $config.General.apply_default_country eq "Y" or $cart.shipping_cost gt 0)} ({include file="currency.tpl" value=$s.rate}){/if}</label></td>

with
Code:
{* ADDED JoltedPixel.com *} {if $s.shippingid == $free_ground_id} {if $free_ground} <td width="5"><input type="radio" id="shippingid{$s.shippingid}" name="shippingid" value="{$s.shippingid}"{if $s.shippingid eq $cart.shippingid} checked="checked"{/if}{if $allow_cod} onclick="javascript: display_cod({if $s.is_cod eq ▒Y▓}true{else}false{/if});"{/if} /></td> <td style="color:#007700; font-weight: bold; text-size: 11px;"><label for="shippingid{$s.shippingid}">{$s.shipping|trademark:$insert_trademark}{if $s.shipping_time ne ""} - {$s.shipping_time}{/if}{if $config.Appearance.display_shipping_cost eq "Y" and ($login ne "" or $config.General.apply_default_country eq "Y" or $cart.shipping_cost gt 0)} ({include file="currency.tpl" value=$s.rate}){/if}</label></td> {/if} {else} <td width="5"><input type="radio" id="shippingid{$s.shippingid}" name="shippingid" value="{$s.shippingid}"{if $s.shippingid eq $free_ground_id_next} checked="checked"{/if}{if $allow_cod} onclick="javascript: display_cod({if $s.is_cod eq ▒Y▓}true{else}false{/if});"{/if} /></td> <td><label for="shippingid{$s.shippingid}">{$s.shipping|trademark:$insert_trademark}{if $s.shipping_time ne ""} - {$s.shipping_time}{/if}{if $config.Appearance.display_shipping_cost eq "Y" and ($login ne "" or $config.General.apply_default_country eq "Y" or $cart.shipping_cost gt 0)} ({include file="currency.tpl" value=$s.rate}){/if}</label></td> {/if} {* END JoltedPixel.com *}

Step 3
Add this line in skin1/main/product_details.tpl (Around line 300)

Code:
<option value=▓G'{if $product.free_shipping eq ▒G▓} selected="selected"{/if}>Free Ground Shipping</option>


The whole chunk should look like this:

Code:
<select name="free_shipping"> <option value=▓G'{if $product.free_shipping eq ▒G▓} selected="selected"{/if}>Free Ground Shipping</option> <option value=▓N'{if $product.free_shipping eq ▒N▓} selected="selected"{/if}>{$lng.lbl_no}</option> <option value=▓Y'{if $product.free_shipping eq ▒Y▓} selected="selected"{/if}>{$lng.lbl_yes}</option> </select>



Technical Notes:
1) In order for the free shipping to show in the shipping methods all products in the cart must be set to ⌠Free Ground Shipping■. The conditions of the shipping zone and charge field must also be met.
2) Currently if a customer adds any products that are not free ground shipping they will void any products that are free ground shipping. So if you have a large item that is free ground shipping and adds something small but not free ground shipping they will ground shipping on both.
__________________
4.1.9
Reply With Quote