VirtueMart Forum

VirtueMart 1.1.x [ Old version - no longer supported ] => Shipping VM 1.1 => USPS (U.S. Postal Service) VM 1 => Topic started by: pinksnyper on December 10, 2011, 23:29:04 PM

Title: Add tax to ship rates only in same state
Post by: pinksnyper on December 10, 2011, 23:29:04 PM
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?
Title: Re: Add tax to ship rates only in same state
Post by: pinksnyper on December 22, 2011, 12:42:10 PM
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;
}
}
Title: Re: Add tax to ship rates only in same state
Post by: lowmips on December 22, 2011, 15:30:13 PM
use "vmGet" instead of mosGetParam
Title: Re: Add tax to ship rates only in same state
Post by: pinksnyper on December 22, 2011, 18:17:54 PM
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