US state based Destination Shipping

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
njmeyer
Forum Members
Forum Members
Posts: 16
Joined: Thu Jun 19, 2008 7:04 pm

US state based Destination Shipping

Post by njmeyer »

I would like to modify the destination based shipping module to use the states rather than the countries to produce the shipping costs.  Anyone know how to do this?  I am assuming that it would not be too bad with using the CGExtensions.

Thanks
njmeyer
kurashiki_ben
Forum Members
Forum Members
Posts: 86
Joined: Sun Jul 05, 2009 2:37 am

Re: US state based Destination Shipping

Post by kurashiki_ben »

njmeyer wrote: I would like to modify the destination based shipping module to use the states rather than the countries to produce the shipping costs.  Anyone know how to do this?  I am assuming that it would not be too bad with using the CGExtensions.

Thanks
njmeyer
This is a really late reply, but it IS possible if you are prepared to modify the Destination Based Shipping module.
Based on DestinationBasedShipping version 1.1

STEP 1
Open DestinationBasedShipping.module.php file

Change line 40
from

Code: Select all

  var $_destination_country;
to

Code: Select all

  var $_destination_state;
Change lines 177-198 to:

Code: Select all

  /*---------------------------------------------------------
   SetAdditionalInfo()
   ---------------------------------------------------------*/
  function SetAdditionalInfo($destination_address)
  {
    if( is_array($destination_address) )
      {
	if( isset($destination_address['state']) )
	  {
	    $this->_destination_state = $destination_address['state'];
	  }
	else if( isset($destination_address['dest_state']) )
	  {
	    $this->_destination_state = $destination_address['dest_state'];
	  }
	else if( isset($destination_address['shipping_state']) )
	  {
	    $this->_destination_state = $destination_address['shipping_state'];
	  }
      }
    $this->_destination_address = $destination_address;
  }    
change line 206
from

Code: Select all

    if( empty($this->_destination_country) )
to   

Code: Select all

if( empty($this->_destination_state) )
change line 229
from

Code: Select all

if( $this->_destination_country != $row['label'] )
to

Code: Select all

if( $this->_destination_state != $row['label'] )
Basically, you can do a find replace for country and change it to state.


STEP 2

Open function.admin_settings_tab.php

Change line 54-55
from:

Code: Select all

$smarty->assign('input_label',
		$this->CreateInputCountryDropdown($id,'input_label','',true));

to:

Code: Select all

$smarty->assign('input_label',
		$this->CreateInputStateDropdown($id,'input_label','',true));
Change line 69
from:

Code: Select all

    $obj->input_label = $this->CreateInputCountryDropdown($id,'label[]',$row['label']);
to:

Code: Select all

    $obj->input_label = $this->CreateInputStateDropdown($id,'label[]',$row['label']);
Again a find replace for Country to State will do the job
clj83
Forum Members
Forum Members
Posts: 195
Joined: Tue Jul 07, 2009 4:09 pm

Re: US state based Destination Shipping

Post by clj83 »

Hi,

Did you ever achieve a working state based shipping solution? I also need a state based shipping solution although I need to use European states in and around the Alps, so unfortunately this list requires states from France, Italy & Switzerland. Does anyone know if this would be possible to achieve? I dont really want to hack the module but I guess that may be my only option.

Thanks

Chris
kurashiki_ben
Forum Members
Forum Members
Posts: 86
Joined: Sun Jul 05, 2009 2:37 am

Re: US state based Destination Shipping

Post by kurashiki_ben »

Hi Chris,

I acheived this perfectly for Japanese prefectures using the above solution.

But, you might be able to do it without the hack by creating the country and states you need in the latest version of orders.
If you did this, put the state options in the country box and the country options in the state box.
Your state options should then appear in the DBS module.

Then swap the labels for country and state in the module templates.

It's a bit hacky in itself and maybe not so good if it's for a client, but I would say the only other option is to hack the module, unless somebody wants to take my hack of Calguys module and create a StateBasedShipping module from it?

Regards

Ben
Dramatic

Re: US state based Destination Shipping

Post by Dramatic »

I have a similar situation, complicated by the fact that I have to follow a courier charging scheme, not any info that is in a standard address:
My shipping options are:
Pick-up (free)
The city the vendor is in
The region the vendor is in
Rest of the country (urban)
rest of the country (rural)

I've created a field with these possible values in FEU but I'm guessing that CreateInputStateDropdown() is a library function tucked away somewhere in core?

I was hoping for a module where you simply define your shipping zones. This isn't it, but it's the nearest I've found.
Post Reply

Return to “Modules/Add-Ons”