Page 1 of 1
US state based Destination Shipping
Posted: Tue Feb 24, 2009 4:01 pm
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
Re: US state based Destination Shipping
Posted: Sat Sep 26, 2009 8:25 am
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
to
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
Re: US state based Destination Shipping
Posted: Wed Apr 07, 2010 3:13 pm
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
Re: US state based Destination Shipping
Posted: Thu Apr 08, 2010 2:22 pm
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
Re: US state based Destination Shipping
Posted: Tue Oct 23, 2012 10:05 pm
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.