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

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 18 2025 14:55:56
Script start
Timing: Jan 18 2025 14:55:56
Module start 'layout'
Timing: Jan 18 2025 14:55:56
Module start 'content'
Timing: Jan 18 2025 14:55:57
Module end 'content'
Timing: Jan 18 2025 14:55:57
Script end

Main resources:

Total runtime0.8146 sec
Peak memory usage4,096.0000 KB
Database Queries54

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0071 589.1797152.6406
Module start 'layout' 0.00710.0036 741.820339.4766
Module start 'content' 0.01070.8024 781.2969473.7891
Module end 'content' 0.81310.0015 1,255.085912.1250
Script end 0.8146  1,267.2109 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00320.3947160.0002
Check MTime0.00140.1730160.0001
Mysql Total
Database connection0.00130.155110.0013
Mysqli_queries0.766594.0968540.0142
Looping result0.00040.0535520.0000
Template Total0.784796.320.3923
Template load0.00200.245820.0010
Template processing0.782796.075320.3913
Template load and register function0.00020.027610.0002
states
state_id_array0.00110.138110.0011
state_identifier_array0.00080.103220.0004
Override
Cache load0.00170.2040570.0000
Sytem overhead
Fetch class attribute can translate value0.00060.077220.0003
Fetch class attribute name0.00160.200120.0008
XML
Image XML parsing0.00030.032220.0001
class_abstraction
Instantiating content class attribute0.00000.001120.0000
General
dbfile0.00110.1401100.0001
String conversion0.00000.000840.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
2content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
8content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
9content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 21
 Number of unique templates used: 5

Time used to render debug report: 0.0001 secs