the target of this module is not only trying to replace the default currency formatting of e-comm which provide by payment.module, but a complete feather for handling multiple currency management. i chose osCommerce as clone target.

currenct functions of this module:

  1. add multiple currency support to e-comm: provide a function function ecurrency_format($from, $to, $price) for formatting the price, according to the given base currency and display currency, with foregin exchange rate applied. other module can apply this function rather then payment_format(). this will be useful for both single/multiple base currency case: store with only one base currency (e.g. implementation of osCommerce), or difference base currency for individual product (e.g. eBay auction system)
  2. admin can add as many as currency format they need
  3. exchange rate can be handle manually or update by using currency_api.module
  4. update by using currency_api.module can be handle manully or by cron

coming on targets:

  1. a block for customer to change their currency display format on the fly, although they are anonymous user, as like as what osCommerce provided. i have try to implement this before in #72068, but this will not be function if drupal cache is on. that needs more work ;-)
  2. change back to base currency when check out (implementation of osCommerce). i found that it is a good idea for accounting: maintain the book clean in one currency format. this will work for single base currency store (multiple product + single currency = base currency check out) or eBay like auction system (single product + product individual currency = product base currency checkout). this will need work within other module (hack), may be after this module (the api) is totally function ;-)

Regards,
Edison

Comments

hswong3i’s picture

hswong3i’s picture

Title: New module: ecurrency.module » Mulriple currency module
Component: CVS » -- other --
Status: Needs review » Active
StatusFileSize
new5.31 KB

new function:

  1. an implementation of hook_block, for changing display currency. mainly copy from old implementation. note that if cache is on, this block will not show out (due to the similar case of cart.module face)
  2. if hope to use eurency_format as default output, only need a simple hack to payment_format:
    /**
     * Format the price according to payment_settings() config options.
     */
    function payment_format($price) {
      if (module_exist('ecurrency')) {
        return ecurrency_format(variable_get('ecurrency_default_base', 1), ecurrency_get_display(), $price);
      }
    
      $price = number_format((float) $price,
        variable_get('payment_decimal_places', 2), 
        variable_get('payment_decimal', '.'), 
        variable_get('payment_thousands', ','));
      return (variable_get('payment_symbol_position', 1) == 1) ? variable_get('payment_symbol', '$') . $price : $price . variable_get('payment_symbol', '$');
    }
    
hswong3i’s picture

Title: Mulriple currency module » Multiple currency module
hswong3i’s picture

StatusFileSize
new5.18 KB

now i move the code to my sendbox:
http://cvs.drupal.org/viewcvs/drupal/contributions/sandbox/hswong3i/ecur...

for version 1.2:

  1. fix .install script. the insert of first 2 example currency will now handle correctly
  2. move style of price and block to css
  3. tweak to db query. most of the query are cached within same page generation.
  4. the API function are now ready:
    1. ecurrency_format($from, $to, $price): Format the price according to input currency format.
    2. ecurrency_get_currencies(): Return an array of all currency objects.
    3. ecurrency_get_currencies_list(): Return an list of all currency objects.
    4. ecurrency_get_currency: Return the currency object matching a currency ID.

i have test both install and configuration, with a small hack to payment.module. again, if you hope to test it out, here are the demo pages:
http://edin.no-ip.com/drupal2/
http://edin.no-ip.com/drupal2/?q=admin/store/settings/ecurrency

sime’s picture

Status: Active » Needs review

hswong3i, as we discussed on IRC, you would like to move this code into CVS.

So what we need is a unified patch. If you need patches in other files, please include them in the patch. I think gordon will need to approve the first major patch.

hswong3i’s picture

StatusFileSize
new23.93 KB

the patch to other module is a bit simple: as stay above, to payment.module
and here is the patch, thank you ;-)

sime’s picture

StatusFileSize
new23.88 KB

Here's a patch that works for me.

hswong3i’s picture

StatusFileSize
new24.37 KB

i fix the patch
and test in within window and linux
by using "patch -p1 < ecurrency.patch" in dir "ecommerce"

havoc’s picture

what's the status on this module? Is it still under active development, or has it been "put on the back burner?"

sun’s picture

Status: Needs review » Needs work

Do not use code separators like:

********************************************************************
* Drupal Hooks
********************************************************************

Do not use ending PHP tag at the end of your files:

?>

Learn more about Drupal coding guidelines here.

hswong3i’s picture

sorry that since i am too busy these days and so don't have time to update this.
i have already move the development to my other modules : the etax, ecurrency, etc

too upset that not much consideration (may be we don't really need such functions), therefore i stop my development right now :"(

sime’s picture

I am still aware of this module. hswong3i has done a lot of work on this.

sime’s picture

You know. I'm going to commit this as a contrib to HEAD, and will sort out the issues sun mentioned

But... can I change the name "ecurrency" to "ec_currency"? This would be more in line with the naming convention we are starting to use.

sun’s picture

@hswong3i: My intention was not to blame you. Please don't misunderstand my comment. It's just that any code for Drupal can be developed faster and better if it adheres to Drupal coding guidelines. The more it adheres, the more it can be supported by various developers.

+1 for this badly needed module (didn't tried the patch though)

sun’s picture

+1 for naming it ec_currency

hswong3i’s picture

as a contributor, i don't care if the name need to be changed ;-)
sorry for my careless about the understanding of drupal coding style, i will learn it.

on the other hand, during my developing i notice that if i keep on develop base on the current ECOM arch, it is not easy to add the localization handling. for example, after handling the tax, i found that if we need to count tax due to location, the address handling need to be update, too. but then when i as gorden if it is possible to change the address.module, the reply is: it is base on store's table, and so...

the idea is: location handling -> taxes -> address (oops) -> store (OOPS)...

BTW since this module only handling currency foramting, i think it can be accept as alone. and for this single idea, i think it is now good enough ;-)

sun’s picture

@hswong3i: If you're working on taxes, we might join our forces. I don't know if you're aware of this short feature overview I've created a while ago. Sorry to nag, but let us please use E-Commerce Group or IRC to exchange development issues that do not directly relate to this issue. Let's discuss just one topic in one issue.

sime’s picture

Status: Needs work » Fixed

I've commited the module to HEAD as ec_currency. To get this tagged 4.7 we need user feedback and also Gordon prefers to have a dedicated maintainer. I recommend new tickets - I'm closing this one.

Regarding tax. Yes, don't try too hard to work with current tax.module. It's stale.

Anonymous’s picture

Status: Fixed » Closed (fixed)