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; }
|