Kryptronic Software Support Forum

You are viewing this forum as a guest. Login to an existing account, or create a new account, to reply to topics and to create new topics.

#1 04-27-2007 09:02:27

TerryA
Member
From: Sanford, Fl
Registered: 07-14-2003
Posts: 1322
Website

Free shipping to local zipcodes

I have been talking to rachaelseven about doing a shipping mod for me that would allow free shipping to certain zipcodes that would be listed in a file, anything that comes from outside the zipcode list would be sent to UPS Tools. She has decided to do the mod and post it on the forum for everyone to have access to!  Don't you just love her?

I started this thread so she can post the code changes when she has it ready.

Offline

 

#2 04-27-2007 19:27:58

Big Dave
Member
Registered: 10-24-2003
Posts: 742

Re: Free shipping to local zipcodes

Rachael is the most generous free code provider to ever grace these boards. She ROCKS!!!!

Offline

 

#3 04-28-2007 10:33:29

rachaelseven
Member
From: Massachusetts, USA
Registered: 01-23-2006
Posts: 3169
Website

Re: Free shipping to local zipcodes

And here it is...

This is a modification (hack) that will allow you to specify a special shipping method for a list of local zip codes you supply. For example, you could offer in store pickup, free local delivery by your truck, etc. It can be fully configured through the shipping settings page of the CCP51 admin area (including disabling it) and is compatible with any of the realtime shipping methods, as well as product based shipping.  It isn't directly set up to work with custom shipping methods (they're unaffected), since theoretically this sort of coding can be done right in the custom shipping script. The new variables will be available to use in your custom shipping scripts though, and I expect having the list of local zip codes stored will slightly ease writing of such scripts. In any case, the mod was requested for realtime shpping and I went ahead and added product based for some extra functionality - custom shipping script users, keep right on coding :-)  Hopefully some of you that are still using 5.1 will find this mod useful... at least I know Terry will smile



In the admin area, under Shipping Settings, you will have five new settings after installation of the mod.  This is what each setting does:

1. Local Shipping Active - This sets whether or not the special local shipping will be applied.  It has three choices:


2. Name for Local Shipping - This is the name that will be shown to the customer for the local shipping option at checkout and also what will appear on the invoices. The default value is "Local Delivery". Other examples could be "In Store Pickup", "Delivery on Our Truck", etc. Any text string is fine, but don't use any colons ( : ).

3. Price for Local Shipping - This is provided in case you want to charge for the local shipping option. The default value is 0.00 (free). You can put in any value you want to charge (just the numbers, no currency symbol). The display in the checkout will be "Name for Local Shipping - Price", unless the price is 0 (see #4). So as an example, if you set the price at 5.00 and left the name on the default, the display next to the radio button would read "Local Delivery - $5.00".

4. Text for Free Local Shipping - This is the string that will be used instead of the price in the checkout display if the local shipping is free. The default value is "Free". So, with the default name, the display next to the radio button would be "Local Delivery - Free". You could also enter "No Charge", "Gratis", "On The House", etc. If you leave this field blank, the display will always show the price - in other words, it will read "Local Delivery - $0.00" when the price is set to zero.

5. Zipcodes for Local Shipping (Comma Separated List) - This is pretty self-explanatory. Enter a comma-separated list of zipcodes where the local shipping option will apply. Zipcodes not in the list will be treated as they always have. The script only looks at the first 5 digits of the zipcode (it's assuming a US format), so no need to enter zip+4.



Before you proceed with this modification, please keep in mind the following very important points:






In this step, we will be editing the file ccp51/data/tables/settings.csv. Be sure you have a current copy from your website so you don't alter any other settings.  At the end of the file, add the following five lines:

Code:

ship_local_active,SHIPPING,Local Shipping Active,D,SELECT-CUSTOM,"Local Shipping Disabled:D|Local Shipping Only, When Applicable:L|Local Shipping & Regular Shipping:B",Y
ship_local_name,SHIPPING,Name for Local Shipping,Local Delivery,TEXTBOX-REG,,Y
ship_local_price,SHIPPING,Price for Local Shipping,0.00,TEXTBOX-REG,,Y
ship_local_freelabel,SHIPPING,Text for Free Local Shipping,Free,TEXTBOX-REG,,N
ship_local_zipcodes,SHIPPING,Zipcodes for Local Shipping (Comma Separated List),,TEXTAREA-SMALL,,N

Save and upload the file.



This step involves several changes to the file /cgi-bin/ccp51/library/modules/ste_checkout.pl.

Change #1 - Find the following code (line 2705):

Code:

@shipid_row = ($cart_prodquantity,$cart_prodshiponename,$cart_prodshiponeprice,$cart_prodshiptwoname,$cart_prodshiptwoprice,$cart_prodshipthreename,$cart_prodshipthreeprice);

And change the above to:

Code:

@shipid_row = ($cart_prodquantity,$cart_prodshiponename,$cart_prodshiponeprice,$cart_prodshiptwoname,$cart_prodshiptwoprice,$cart_prodshipthreename,$cart_prodshipthreeprice,$cart_shipzip);

Change #2 - Find the following code (line 2920):

Code:

($cart_prodquantity,$cart_prodshiponename,$cart_prodshiponeprice,$cart_prodshiptwoname,$cart_prodshiptwoprice,$cart_prodshipthreename,$cart_prodshipthreeprice) = @$row;

And change the above to:

Code:

($cart_prodquantity,$cart_prodshiponename,$cart_prodshiponeprice,$cart_prodshiptwoname,$cart_prodshiptwoprice,$cart_prodshipthreename,$cart_prodshipthreeprice,$dest_postalzip) = @$row;

Change #3 - Find the following code (line 2903):

Code:

$trackitem_ship_options = ste_chkout_meth_realtime_proc($localint,$shiptype,$orig_country,$orig_stateprov,$orig_postalzip,$dest_country,$dest_stateprov,$dest_postalzip,$dest_rescom,@items);

And change the above line to in the following:

Code:

######### Local Delivery Mod

$trackitem_ship_options = "";
$dest_postalzip =~ s/\D//gs;
my $test_zip = substr($dest_postalzip, 0, 5);
my $local_option = "";
my $local_rate = sprintf("%.2f",$ship_local_price);
if ($local_rate >0 || $ship_local_freelabel eq "") {
  $local_option =  "<INPUT TYPE=\"RADIO\" NAME=\"shipinfo-$shipid\" VALUE=\"$ship_local_name\:$local_rate\" CHECKED> <FONT FACE=\"$html_base_font_face\" SIZE=\"$html_base_font_size\" COLOR=\"$html_base_font_color\"> $ship_local_name - $currency_symbol$local_rate<BR></FONT>\n";
} else {
  $local_option =  "<INPUT TYPE=\"RADIO\" NAME=\"shipinfo-$shipid\" VALUE=\"$ship_local_name\:$local_rate\" CHECKED> <FONT FACE=\"$html_base_font_face\" SIZE=\"$html_base_font_size\" COLOR=\"$html_base_font_color\"> $ship_local_name - $ship_local_freelabel<BR></FONT>\n";
} ## endif
if ($ship_local_active =~ /(L|B)/ && $ship_local_zipcodes =~ /$test_zip/) {
  $trackitem_ship_options = $local_option;
} ## endif
if ($ship_local_active =~ /(D|B)/) {
  $trackitem_ship_options .= ste_chkout_meth_realtime_proc($localint,$shiptype,$orig_country,$orig_stateprov,$orig_postalzip,$dest_country,$dest_stateprov,$dest_postalzip,$dest_rescom,@items);
} ## endif

######### End Local Delivery Mod

Change #4 - Find the following code (line 2957):

Code:

$trackitem_ship_options = ste_chkout_meth_default_proc($name1,$price1,$name2,$price2,$name3,$price3);

Change the above line to the following:

Code:

######### Local Delivery Mod

$trackitem_ship_options = "";
$dest_postalzip =~ s/\D//gs;
my $test_zip = substr($dest_postalzip, 0, 5);
my $local_option = "";
my $local_rate = sprintf("%.2f",$ship_local_price);
if ($local_rate >0 || $ship_local_freelabel eq "") {
  $local_option =  "<INPUT TYPE=\"RADIO\" NAME=\"shipinfo-$shipid\" VALUE=\"$ship_local_name\:$local_rate\" CHECKED> <FONT FACE=\"$html_base_font_face\" SIZE=\"$html_base_font_size\" COLOR=\"$html_base_font_color\"> $ship_local_name - $currency_symbol$local_rate<BR></FONT>\n";
} else {
  $local_option =  "<INPUT TYPE=\"RADIO\" NAME=\"shipinfo-$shipid\" VALUE=\"$ship_local_name\:$local_rate\" CHECKED> <FONT FACE=\"$html_base_font_face\" SIZE=\"$html_base_font_size\" COLOR=\"$html_base_font_color\"> $ship_local_name - $ship_local_freelabel<BR></FONT>\n";
} ## endif
if ($ship_local_active =~ /(L|B)/ && $ship_local_zipcodes =~ /$test_zip/) {
  $trackitem_ship_options = $local_option;
} ## endif
if ($ship_local_active =~ /(D|B)/) {
  $trackitem_ship_options .= ste_chkout_meth_default_proc($name1,$price1,$name2,$price2,$name3,$price3);
} ## endif

######### End Local Delivery Mod



The mod is installed in the turned off configuration - to start using it, go into your CCP admin area, under Shipping Settings->Manage Shipping Settings. Add your list of zipcodes, change name and price if desired, set the active mode you want and submit. Customers will begin seeing the new option immediately. If you want turn it off (like your truck broke down and you can't deliver locally), you don't need to clear the list of zipcodes; just change the active setting to 'Local Shipping Disabled' and the option won't be presented in the checkout.



If you have a long list of zipcodes and can't fit them all in the 200 character limit of the field in the admin, you will need to perform this optional step. Without doing this step, you can already store 33 zipcodes (5 digits plus a comma x 33 = 198). Most people will need far less than that, so this step is unecessary and undesirable for most users. But in that rare case where you just have to have 34 or more local zipcodes, perform the following final step.

In this step, we will be editing the file ccp51/data/tables/config_settings.csv to allow for longer setting values in the admin area so you can put in enough zipcodes to make the mod useful. Find the code:

Code:

settings_display_value,SYSTEM,Administration Display Value,200,N,,,,N

And change the above to:

Code:

settings_display_value,SYSTEM,Administration Display Value,255,N,,,,N

Save and upload the file.



That's about it. As I said, back up your files before you start changing them and use at your own risk. It's been lightly tested on my site and seems to work fine. But nevertheless, be sure to run your own tests to make sure all is well. If you find any bugs, let me know and I'll do my best to sort it out when I get a chance.

Enjoy!

Rachael smile


Rachael Katz
- Custom Focusing Screens for DSLR Cameras

Offline

 

#4 05-01-2007 10:12:52

TerryA
Member
From: Sanford, Fl
Registered: 07-14-2003
Posts: 1322
Website

Re: Free shipping to local zipcodes

You ROCK girl!  Looks like it is working like a charm.

Offline

 

Board footer