Author Topic: Add tax to ship rates only in same state  (Read 2869 times)

pinksnyper

  • Beginner
  • *
  • Posts: 28
Add tax to ship rates only in same state
« 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?

pinksnyper

  • Beginner
  • *
  • Posts: 28
Re: Add tax to ship rates only in same state
« Reply #1 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

Code: [Select]
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

  • Global Moderator
  • Full Member
  • *
  • Posts: 1464
    • lowmips.com
Re: Add tax to ship rates only in same state
« Reply #2 on: December 22, 2011, 15:30:13 pm »
use "vmGet" instead of mosGetParam
Visit my website at www.lowmips.com
View my newsletters Here (sign up for newsletters on the front page of my website)

pinksnyper

  • Beginner
  • *
  • Posts: 28
Re: Add tax to ship rates only in same state
« Reply #3 on: December 22, 2011, 18:17:54 pm »
use "vmGet" instead of mosGetParam

Holy crap it WORKED! THANK YOU a million times over