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-04-2007 13:21:55

lowayne
Member
Registered: 09-19-2006
Posts: 8

Idea for free shipping for local zip codes.

I have been working to get free shipping to customers in 5 local zip codes without breaking realtime USPS shipping. There are great scripts for CCP5.1 but I am having trouble moving them over to CCP6.

So I had an idea, tell me if it it is good or how I could go about implementing it.

With CCP6 we have a lovely feature to give free shipping to orders over x dollars for the entire store (this is great when you have hundreds of products to modify shipping methods on). In theory couldn't we add some if/elseif statements to grant free shipping to orders of 0 dollars to certain defined zip codes? This would give free shipping to any product shipped locally, I hope!

Offline

 

#2 04-11-2007 12:52:45

lowayne
Member
Registered: 09-19-2006
Posts: 8

Re: Idea for free shipping for local zip codes.

No one has any thoughts/suggestions on this idea?

Offline

 

#3 04-12-2007 21:06:15

dh783
Moderator
From: Avondale, Arizona
Registered: 04-06-2005
Posts: 6233
Website

Re: Idea for free shipping for local zip codes.

I did some thinking on this and this is what I came up with. Make a backup of files so if you do something wrong you can correct it. This is also subject to be over written with an update, and use at your own risk.

1. I created two new fields in admin Home > Kryptronic Hybrid X Core > Database: Connections, Backups and Raw Admin > Raw Database Admin>khxc_settings.

  first field info:

     id              = ccp0.shipzipactive
     name        = Shipping Zip Active
     app           = ccp0
     section      = Shipping Settings
     displaytye = SELECT-BOOL
     required    = 1
     value        = 0
     description = To allowe free shipping on zip code set this value to true to allow shipping to defined zip codes.

field two

     id              = ccp0.shipzipfree
     name        = Shipping Zip List
     app           = ccp0
     section      = Shipping Settings
     displaytye = TEXTAREA-SMALL
     required    = 0
     value        ="input comma seperated list of zip codes"
     description = Enter a comma seperated list fo zip codes you would like to give free shipping too.

This will give you two new fields in the front end admin Settings: Application Settings Menu > Application Settings Menu>Shipping Settings that will allow you to activate the free shipping and make a list of zip codes.

Then in {private}/apps/ccp0/CCP_Ship/CCP_Ship.php just after:

Code:

// +--
// | Work with our shipinfo array some more.  We want to handle free
// | shipping and handling charges here.
// +--

$freeship = $this->globals('khxc_settings.' . $this->app . '.freeshipamt');
$handling = $this->globals('khxc_settings.' . $this->app . '.shiphandlecharge');

I added:

Code:

$freezipship  = $this->globals('khxc_settings.' . $this->app . '.shipzipfree');

$shipzipfree = explode(',',$freezipship);
$zipcount = '0';

foreach ($shipzipfree as $num => $freezip) {

     if ($freezip == $sihash['postalcode']) {$zipcount = '1';}

} // End of foreach.

if (($this->globals('khxc_settings.' . $this->app . '.shipzipactive') == true) && (!(empty($zipcount))) && (!(empty($shipinfo)))) {


     $xshipinfo = array();

     foreach ($shipinfo as $group => $options) {

          // +--
          // | Add in handling charges.
          // +--

          if ($handling > 0) {

               foreach ($options as $key => $data) {

                    $options[$key]['amount'] = $data['amount'] + $handling;

               } // End of foreach statement.

               if ($this->debug) {$this->debugger("coship: Applied handling charge of '{$handling}'.");}

               // +--
               // | Update all of our realtime shipper info arrays to
               // | include the handling disclaimer.
               // +--

               $zshipinfo = $this->globals('ecom.ship_shipinfo');

               if (!(empty($zshipinfo))) {

                    foreach ($zshipinfo as $zshipper => $zinfo) {

                         $zshipinfo[$zshipper]['shipper_info']['show_handledisc'] = 1;

                    } // End of foreach statement.

                    $this->globals('ecom.ship_shipinfo',$zshipinfo);

               } // End of if statement.

          } // End of if statement.

          // +--
          // | Handle free shipping.
          // +--

               // +--
               // | Get the amount for the first item in the array.
               // +--

               foreach ($options as $key => $data) {

                    $xamount = $data['amount']; break 1;

               } // End of foreach statement.

               // +--
               // | Subtract that amount from all of the shipping
               // | options.
               // +--

               foreach ($options as $key => $data) {

                    $amount = $data['amount'] - $xamount;

                    if ($amount <= 0) {$amount = 0;}

                    $options[$key]['amount'] = $amount;

               } // End of foreach statement.

               if ($this->debug) {$this->debugger("coship: Applied free shipping discount of '{$xamount}'.");}

          $xshipinfo[$group] = $options;

     } // End of foreach statement.

     // +--
     // | Copy $xshipinfo over to our $shipinfo var.
     // +--

     $shipinfo = $xshipinfo;

     if ($this->debug) {$this->debugger("coship: Completed modifying shipping options for handling fees and free shipping.");}

} else {

then a little further down at:

Code:

     // +--
     // | Copy $xshipinfo over to our $shipinfo var.
     // +--

     $shipinfo = $xshipinfo;

     if ($this->debug) {$this->debugger("coship: Completed modifying shipping options for handling fees and free shipping.");}

 } // End of if statement.

add this just after the above code

Code:

 
} // End of if statement.

I have tryed this on my site with no free shipping and it gives the first lowest shipping price free to the zip codes I have listed.

John

Last edited by dh783 (07-17-2007 06:04:10)

Offline

 

#4 04-13-2007 13:34:05

dh783
Moderator
From: Avondale, Arizona
Registered: 04-06-2005
Posts: 6233
Website

Re: Idea for free shipping for local zip codes.

I have edited the post above to get the script to use both the zip code or the free ship over total script to work. I combined the first two if statements into:

Code:

if (($this->globals('khxc_settings.' . $this->app . '.shipzipactive') == true) && (!(empty($zipcount))) && (!(empty($shipinfo)))) {

and removed one bracket just befor the else statement .

John

Offline

 

#5 04-13-2007 13:40:08

picstart
Member
From: United Kingdom
Registered: 07-11-2006
Posts: 428

Re: Idea for free shipping for local zip codes.

would this work for the uk version, and is it possible to make this as a collect from store option if the post codes (zip codes) matched the pre defined list?


"It may be my worst nightmare at present..... but soon it will be my dream"

Offline

 

#6 04-13-2007 14:50:35

dh783
Moderator
From: Avondale, Arizona
Registered: 04-06-2005
Posts: 6233
Website

Re: Idea for free shipping for local zip codes.

I am not sure what the differences between the US and UK versions are if any. I think it should work if the call for the postal code is the same but I would have to see it to be sure.

The main portion of the post is just a copy of the free shipping code that would already be there minus the if statements that look for the freeship total amount, so it shouldn't be hard to modify it. The postal code varaible would be defined futher up in the script so you could change that if needed.

If you wanded a selection for instore pickup that would have to be done somewhere else as this part of the code is just working with the shipping amounts that are being returned from what shipper the products are calling.

John

Offline

 

#7 04-16-2007 13:44:13

lowayne
Member
Registered: 09-19-2006
Posts: 8

Re: Idea for free shipping for local zip codes.

Wow, this goes above and beyond what I had envisioned. This method seemed the most logical way to implement localized free shipping but I needed help with some holes. Great stuff, I am going to work with it and report back later.

Offline

 

#8 07-16-2007 10:15:30

lo_wayne
Member
Registered: 06-12-2007
Posts: 4

Re: Idea for free shipping for local zip codes.

I lost my old password so I am reporting in with a new handle. smile Script has worked wonderfully and anyone should use it wanting these types of features.

Offline

 

#9 07-16-2007 13:34:21

picstart
Member
From: United Kingdom
Registered: 07-11-2006
Posts: 428

Re: Idea for free shipping for local zip codes.

Hi lo_wayne,
did you make any changes to the above scripting to make it work,

if so can you publish them here

regards Mark


"It may be my worst nightmare at present..... but soon it will be my dream"

Offline

 

#10 07-17-2007 11:04:19

dh783
Moderator
From: Avondale, Arizona
Registered: 04-06-2005
Posts: 6233
Website

Re: Idea for free shipping for local zip codes.

Hi picstart,

I think your problem with not getting this to work deals with the fact that UK uses numbers and letters in your postal codes (since the only code I know has them). I did a test on my site with a postal code with a letter in it and it did not work so I think we need a way to compair a mixed varaible.

John

Offline

 

#11 07-17-2007 13:29:59

dh783
Moderator
From: Avondale, Arizona
Registered: 04-06-2005
Posts: 6233
Website

Re: Idea for free shipping for local zip codes.

The only postal code I know for the UK is CMC9 4NJ, it seemed that the origanel code did work as long as there where no spaces. This code in place of the origanel matched postal codes with spaces but both the customers zip and the list of zip codes had to be the same (with or with out spaces).

Code:

if (eregi($sihash['postalcode'],$freezip)) {$zipcount = '1';}

it replaced

Code:

if ($freezip == $sihash['postalcode']) {$zipcount = '1';}

so i guess the question is how do you and your customer enter there zipcodes.

John

Offline

 

#12 01-07-2011 12:22:16

kreinbrink
Member
From: Orlando
Registered: 11-16-2009
Posts: 163
Website

Re: Idea for free shipping for local zip codes.

John,

Is this mod able to be "reversed"?  Currently FedEx has rural, extended rural, etc surcharges based on delivery zip codes.  Would it be possible to pass these fees to the customer based on their zip codes as a shipping surcharge using the same zip code csv list in your post?  Currently we offer free shipping over $30.00 but would like there to be a shipping surcharge based on these zip codes.  There are I believe three separate flat rate surcharges they have, so we would have 3 csv lists based on delivery zip codes where these surcharges would be in effect.  Say a customer orders over $30.00 but lives in an extended residential zone where the surcharge we pay is 2.13.  So in this case, the customer would pay their total price + 2.13 shipping.

Last edited by kreinbrink (01-07-2011 12:28:52)


Ben
  : CCP7 w/ Joomla Integration

Offline

 

#13 01-07-2011 20:39:10

dh783
Moderator
From: Avondale, Arizona
Registered: 04-06-2005
Posts: 6233
Website

Re: Idea for free shipping for local zip codes.

Are you sure that these charges are not already being returned by Fedex thru the normal ccp realtime script? I would think that if Fedex charged this that it should already be included, since the original shipping request is sent the zip code.

John

Offline

 

#14 01-10-2011 10:00:09

kreinbrink
Member
From: Orlando
Registered: 11-16-2009
Posts: 163
Website

Re: Idea for free shipping for local zip codes.

Well I guess therein lies the problem, we are charging free shipping on orders greater than $30.00 so after that threshold, those extended charges are being covered by us which ends up being almost 30% of the shipping costs on some occurrences.   Its only after that $30 dollar threshold that we want to charge those zip codes the extra "handling" fee or what have you.


Ben
  : CCP7 w/ Joomla Integration

Offline

 

#15 01-10-2011 12:45:45

dh783
Moderator
From: Avondale, Arizona
Registered: 04-06-2005
Posts: 6233
Website

Re: Idea for free shipping for local zip codes.

Well I implemented code that on free shipping it would only allow a specified amount, in my case it is set at 25 dollars so that even if the order exceeds the shipping threshold amount the site will charge shipping in excess of 25 dollars as well as limiting free shipping to within the home country. If I remember right I posted these mods on the forum, or I do know that the mod to limit free shipping to the home country is posted.

John

Offline

 

#16 01-11-2011 16:48:47

kreinbrink
Member
From: Orlando
Registered: 11-16-2009
Posts: 163
Website

Re: Idea for free shipping for local zip codes.

Could I create two tables on the backend of the shopping cart, one for a delivery area surcharge and one with an extended delivery area surcharge.?  From within a custom shipping script, could an if statement search those tables for the shoppers postal code and display the price accordingly if that zip code is in one of those tables? 

If this is possible, what would be the php function be that would look at one of these tables?  Thank you.


Ben
  : CCP7 w/ Joomla Integration

Offline

 

#17 01-12-2011 11:19:01

kreinbrink
Member
From: Orlando
Registered: 11-16-2009
Posts: 163
Website

Re: Idea for free shipping for local zip codes.

I think I've got it figured out!  This shipping script does 6 things. I created two tables in mysql, one with delivery surcharge zipcodes and another with extended delivery surcharge zipcodes. 

If the order is below 30.00 it charges realtime rates. 
If the order is greater than or equal to 30.00 and it is residential and in a delivery surcharge zipcode, it charges $2.75.
If the order is greater than or equal to 30.00 and it is commercial and in a delivery surcharge zipcode, it charges $1.85.
If the order is greater than or equal to 30.00 and it is residential and in an extended delivery surcharge zipcode, it charges $3.00.
If the order is greater than or equal to 30.00 and it is commercial and in an extended delivery surcharge zipcode, it charges $1.85.
Otherwise it is free shipping with no surcharges.

If any of the bright minds want to comment on the logic, I'd love to see if I did this correctly and if there needs to be any improvements made.  Thanks!

Code:

<?php 

$info = $this->globals('ecom.customship');

$sql1 = mysql_query("SELECT id,zipcode FROM ecom_das");

while ($array1 = mysql_fetch_array($sql1))
{
$data1[] = $array1[1];
}

$sql2 = mysql_query("SELECT id,zipcode FROM ecom_exdas");

while ($array2 = mysql_fetch_array($sql2))
{
$data2[] = $array2[1];
}

$method0 = 'FedEx Ground';
$method1 = 'Free FedEx Home Delivery with Delivery Area Surcharge';
$method2 = 'Free FedEx Ground with Delivery Area Surcharge';
$method3 = 'Free FedEx Home Delivery with Extended Delivery Area Surcharge';
$method4 = 'Free FedEx Ground with Extended Delivery Area Surcharge';

$delinfo = array('stateprov'     => $info['stateprov'],
                 'country'       => $info['country'],
                 'postalcode'    => $info['postalcode'],
                 'rescom'        => $info['rescom'],
                 'shipstateprov' => $info['shipstateprov'],
                 'shipcountry'   => $info['shipcountry'],
                 'shipzip'       => $info['shipzip'],
                 'shipmethods'   => 'FEDEX',
                 'shiptype'      => 'R');

if ($info['total'] >= '0' && $info['total'] <= '29.99') {

$result = $this->include_namespace('ecom','shiprealtime',array('delinfo'  => $delinfo, 'packages' => $info['packages']));
foreach ($result as $num => $service) {$custom[$service['name']] = $service['amount'];}

} elseif ($info['total'] >= '30.00' && $info['rescom'] == 'R' && in_array($info['postalcode'], $data1)) {
    
     $custom = array($method1 => '2.75');

} elseif ($info['total'] >= '30.00' && $info['rescom'] == 'C' && in_array($info['postalcode'], $data1)) {
    
     $custom = array($method2 => '1.85');

} elseif ($info['total'] >= '30.00' && $info['rescom'] == 'R' && in_array($info['postalcode'], $data2)) {
    
     $custom = array($method3 => '3.00');

} elseif ($info['total'] >= '30.00' && $info['rescom'] == 'C' && in_array($info['postalcode'], $data2)) {
    
     $custom = array($method4 => '1.85');

} else {

     $custom = array($method0 => '0.00');

} // End of if statement.

$this->globals('ecom.customship_response',$custom);

?>

Ben
  : CCP7 w/ Joomla Integration

Offline

 

Board footer