Making PayPal Extension to work with Multiple Currencies

Author Message

Stuart Fenton

Friday 01 December 2006 6:38:38 am

I have been trying to get the PayPal extension to work with multiple currencies. I can't find any documentation on the subject so I went through some tests and found that it's getting the currency from the Local environment variable and does not pull the currency set by the user.

So the code in ezpaypalgateway.php file in classes looks like this:

        include_once( 'lib/ezlocale/classes/ezlocale.php' );
        $locale         =& eZLocale::instance();
        $currency       = urlencode( $locale->currencyShortName() );

        $countryCode    = urlencode($locale->countryCode());


So I have changed it to read from the users preferences instead.

        include_once( 'lib/ezlocale/classes/ezlocale.php' );
        $locale         =& eZLocale::instance();
        $currency       = urlencode( $locale->currencyShortName() );
        
//SF START - Added for MultiCurrency Support
        include_once( 'kernel/classes/ezpreferences.php' );
        $currency       = eZPreferences::value( 'user_preferred_currency' );
//SF END

        $countryCode    = urlencode($locale->countryCode());

If your going to use it you should add some checking code as this is rough and ready. But it works.

Regards
Fats

-- Stuart

stuart@grandmore.com
http://www.grandmore.com

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 31 2025 01:21:16
Script start
Timing: Jan 31 2025 01:21:16
Module start 'layout'
Timing: Jan 31 2025 01:21:16
Module start 'content'
Timing: Jan 31 2025 01:21:17
Module end 'content'
Timing: Jan 31 2025 01:21:17
Script end

Main resources:

Total runtime0.6904 sec
Peak memory usage8,192.0000 KB
Database Queries46

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0050 588.3906151.2422
Module start 'layout' 0.00500.0040 739.6328220.7500
Module start 'content' 0.00900.6807 960.38284,378.5078
Module end 'content' 0.68970.0007 5,338.89067.7813
Script end 0.6904  5,346.6719 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00360.5183160.0002
Check MTime0.00130.1835160.0001
Mysql Total
Database connection0.00070.106610.0007
Mysqli_queries0.614789.0371460.0134
Looping result0.00050.0669440.0000
Template Total0.641192.920.3206
Template load0.00210.310520.0011
Template processing0.638992.543720.3195
Template load and register function0.00140.203910.0014
states
state_id_array0.00120.180210.0012
state_identifier_array0.00080.117520.0004
Override
Cache load0.00170.2535130.0001
Sytem overhead
Fetch class attribute can translate value0.00170.242910.0017
Fetch class attribute name0.00170.245520.0008
XML
Image XML parsing0.00040.061110.0004
class_abstraction
Instantiating content class attribute0.00000.000720.0000
General
dbfile0.00230.3309160.0001
String conversion0.00000.001040.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
1content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
4content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
2content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
2content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 12
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs