Hello, I have a site based in the uk and want to use this module - which is great and really useful by the way - with UK Pound Sterling as currency. I added this into the code but the £ doesn't seem to show on the page correctly - it renders the html code £ rather than the £ sign. Sorry if this is a newbie question. It does the same thing with the Euro by the way which I haven't altered at all.
Here is the bit that I changed that doesn't appear correctly - I also of course added GBP to the array
/**
* Format currency.
*/
function _signup_pay_format_amount($amount, $currency) {
$amount = number_format($amount, 2);
switch($currency) {
case 'GBP':
return "£ $amount";
case 'EUR':
return "€ $amount";
case 'USD':
return "$ $amount";
case 'CAD':
return "C$ $amount";
default:
return check_plain($currency). " $amount";
}
}
| Comment | File | Size | Author |
|---|---|---|---|
| #9 | signup_pay.module.txt | 31.41 KB | fibie |
| #3 | signup_pay_uk_patch.txt | 31.27 KB | fibie |
Comments
Comment #1
kbahey commentedCan you please format this as a proper patch? See http://drupal.org/patch for details on how to do so.
Thanks in advance.
Comment #2
fibie commentedHi I'm still a bit green about the cvs thing, I had a look and downloaded xcode but will need time to learn how to use it Im afraid - sorry but here is the complete file in text format for starters
What I needed was a registration for a UK conference and so I set about adding in an option for UK Pounds.
I made two small changes. The first to add the currency code for UK Pounds into the array
function signup_pay_get_currency() {
return array(
'GBP' => t('UK Pounds'),
'EUR' => t('Euro'),
'USD' => t('US Dollar'),
'CAD' => t('Canadian Dollar'),
);
}
And then added it as a case to function _signup_pay_format_amount
* Format currency.
*/
function _signup_pay_format_amount($amount, $currency) {
$amount = number_format($amount, 2);
switch($currency) {
case 'GBP':
return "£ $amount"; (
case 'EUR':
return "€ $amount";
case 'USD':
return "$ $amount";
case 'CAD':
return "C$ $amount";
default:
return check_plain($currency). " $amount";
}
}
All that was left to do was make GBP the default currency
define('SIGNUP_PAY_DEFAULT_CURRENCY', 'GBP');
It all seems to work but the UK £ sign doesn't render correctly. It shows the HTML code instead of the £ sign.
Hope that gives u what you need.
I'm not really a developer so apologise for not submitting in the correct format - I will take time to learn how to create a proper patch as soon as I can so I can contribute properly :)
Thanks for your patience meantime
Comment #3
fibie commentedComment #4
kbahey commentedCommitted.
Should be in -dev in 24 hours.
Thank you.
Comment #5
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.
Comment #6
iamwhoiam commentedpound sign still doesn't appear correctly, tried using
££and£all unsuccessfully. Maybe it's to do with the UTF-8 encoding that drupal uses?Comment #7
markfoodyburton commentedon line 671, you should replace %amount with !amount
(Ignore line break)
see: http://api.drupal.org/api/function/t/5
then it works :-)
Cheers
Mark.
Comment #8
kbahey commentedCan someone please submit a working and tested patch?
Comment #9
fibie commentedThis is the version I have been using and it seems to work fine but you will need to apply the additional suggestion by markfoodyburton - I never did get the pound sign to show up correctly. Hope that works for you
Comment #10
kbahey commented@fibie
Your version is way too old. It is from June 1, and version 1.2.2.14. The version in CVS is 1.2.2.19 and is dated June 24.
Too many changes have happened between the versions, and merging your change is impossible.
This is why a patch is best in all situations.