News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Add tax to ship rates only in same state

Started by pinksnyper, December 10, 2011, 23:29:04 PM

Previous topic - Next topic

pinksnyper

I've searched the web and haven't found a solution to this. I would like to tax the ship rates only for in-state orders (if you are in the same state as our shop). Right now the standard configuration allows only NO TAX or YES TAX ON ALL ORDERS but no way to configure otherwise.

Anyone propose a solution/hack to the code?

pinksnyper

I've discovered this fix by another virtuemart user, but I get a mosgetparam error when I try this. Can anyone spot the error? I'm not a developer


function get_tax_rate() {

/** Read current Configuration ***/
require_once(CLASSPATH ."shipping/".$this->classname.".cfg.php");

/** Daniel.UWW MOD QUERY ***/
$auth = $_SESSION['auth'];
$db = new ps_DB;
$shopper_group_id = $auth["shopper_group_id"];
$ship_to_info_id = mosGetParam($_REQUEST, 'ship_to_info_id');
$q = "SELECT state, zip, country FROM #__{vm}_user_info ";
         $q .= "WHERE user_info_id='".@$_REQUEST["ship_to_info_id"] . "'";
         $db->query($q);
         $db->next_record();
         $state = $db->f("state");
/** Daniel.UWW MOD END ***/

if( intval(USPS_TAX_CLASS)== 0 )
return( 0 );
/** Daniel.UWW MOD: Default 0 to tax amount if tax class selected and out of state of GA ***/
elseif (intval(USPS_TAX_CLASS)!= 0 && $state!='GA') {
return( 0 );}
/** Daniel.UWW MOD END ***/
else {
require_once( CLASSPATH. "ps_tax.php" );
$tax_rate = ps_tax::get_taxrate_by_id( intval(USPS_TAX_CLASS) );
return $tax_rate;
}
}

lowmips

Visit my website at www.lowmips.com
View my newsletters Here (sign up for newsletters on the front page of my website)

pinksnyper

Quote from: lowmips on December 22, 2011, 15:30:13 PM
use "vmGet" instead of mosGetParam

Holy crap it WORKED! THANK YOU a million times over