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

CommentFileSizeAuthor
#9 signup_pay.module.txt31.41 KBfibie
#3 signup_pay_uk_patch.txt31.27 KBfibie

Comments

kbahey’s picture

Status: Active » Needs work

Can you please format this as a proper patch? See http://drupal.org/patch for details on how to do so.

Thanks in advance.

fibie’s picture

Hi 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

fibie’s picture

StatusFileSize
new31.27 KB
kbahey’s picture

Status: Needs work » Fixed

Committed.

Should be in -dev in 24 hours.

Thank you.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.

iamwhoiam’s picture

Status: Closed (fixed) » Postponed (maintainer needs more info)

pound sign still doesn't appear correctly, tried using £ £ and £ all unsuccessfully. Maybe it's to do with the UTF-8 encoding that drupal uses?

markfoodyburton’s picture

on line 671, you should replace %amount with !amount

(Ignore line break)

'#value' => t('<div>The price you pay: !amount</div>', array('!amount' => _signup_pay_format_amount($amount,$pay_roles[$default_rid]['currency']))),

see: http://api.drupal.org/api/function/t/5

then it works :-)

Cheers

Mark.

kbahey’s picture

Status: Postponed (maintainer needs more info) » Needs work

Can someone please submit a working and tested patch?

fibie’s picture

StatusFileSize
new31.41 KB

This 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

kbahey’s picture

@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.