Forums / Developer / administrator just like anonymous user for VAT

administrator just like anonymous user for VAT

Author Message

Heather Buch

Friday 27 June 2003 7:59:51 am

I was puzzled over why not only anonymous users, but also the admin user saw prices that included VAT, even when the product specifically excluded VAT, and I had set
PricesIncVATBeforeLogin=enabled.

I think this is because the admin account which is set up in ezpublish 2.2.7 does *not* have a country. The way that ezpublish calculates whether VAT will be shown or not to the logged in user, depends not only on the user being logged in, but also having a country (as you can see in the code snippet below from ezproduct.php). This makes sense as the "new user" form requires a country. But it can be a little confusing if you are logged in as admin, thinking you are a logged in user and wondering why you are seeing VAT included when you have set up the product to exclude it.

Best,
Heather Buch

/*!
Returns the VAT type.

False if no type is assigned.
*/
function vatType( )
{
$user =& eZUser::currentUser();
$ret = new eZVATType();

$ini =& INIFile::globalINI();
if ( $ini->read_var( "eZTradeMain", "PricesIncVATBeforeLogin" ) == "enabled" )
$useVAT = true;
else
$useVAT = false;

if ( $ini->read_var( "eZTradeMain", "CountryVATDiscrimination" ) == "enabled" )
$CountryDisc = true;
else
$CountryDisc = false;


if ( get_class ( $user ) == "ezuser" && $CountryDisc == true )
{
eZLog::writeNotice("the user class for " . $user->name() . " is " .
get_class($user));
$mainAddress = $user->mainAddress();
if ( get_class ( $mainAddress ) == "ezaddress" )
{
$country = $mainAddress->country();
if ( ( get_class ( $country ) == "ezcountry" ) and ( $country->hasVAT() == true ) )
{
eZLog::writeNotice("will use VAT because country " . $country->name() . " has VAT");
$useVAT = true;
}
else
{
eZLog::writeNotice("will use VAT because country " . $country->name() . " does not have VAT");
$useVAT = false;
}
}

}

if ( ( $useVAT == true ) and ( is_numeric( $this->VATTypeID ) ) and ( $this->VATTypeID > 0 ) )
{
$ret = new eZVATType( $this->VATTypeID );
}

return $ret;
}

Heather Buch

Monday 30 June 2003 5:25:59 am

just to elaborate on this a bit - after testing, I have learned that

the "PricesIncVATBeforeLogin" setting in site.ini.php, means that all anonymous users (before login), *and* all logged in users who have not previously bought products will see the prices with VAT added. The only ones who will not see VAT as a result of this setting are customers who have previously bought products and therefore have addresses.

Heather Buch