Hi, I am grateful for your work on this module as I am no programmer, so thank you in advance.
I only need UK pounds on my site and would like to take out the field which gives options to change currency. It doesn't make sense to have a drop down menu when there is only one option in the array. That is not problem but it defaults to USD when the field is removed.
I have simple paypal set to UK pounds and have removed the USD and EUR options from the array in the Simple Paypal module.
I also changed the default currency in the database to GBP in donate but it still comes up as $ when it reaches paypal.
Can you advise? I am sure I must be missing something simple to do.
| Comment | File | Size | Author |
|---|---|---|---|
| #12 | donation-5.x-dev-currency-options1.patch | 5.46 KB | jbomb |
| #9 | donation-5.x-dev_default_currency.patch | 4.63 KB | jbomb |
| #6 | donation-5.x-1.0_default_currency.patch | 2.73 KB | jbomb |
Comments
Comment #1
kbahey commentedIt requires code changes to do this.
These can either be via a form_alter, or changes to the module itself.
Comment #2
fibie commentedOk for the benefit of newbies like me here is what I changed
The lines I removed from the code are:
$form['currency_code'] = array(
'#type' => 'select',
'#title' => t('Currency'),
'#options' => simple_paypal_get_currencies(),
'#name' => 'currency_code',
'#description' => t('The Drupal Association accepts payments in these two currencies.'),
);
and I replaced this with:
$form['currency_code'] = array(
'#type' => 'hidden',
'#value' => 'GBP',
'#name' => 'currency_code'
);
Seems to work but if anyone could tell me if I have done anything fundmentally wrong here it would be appreciated :)
Comment #3
kbahey commentedYour solution is good enough. The fact that you looked up FAPI options and selected hidden is worthy of admiration.
However, if you upgrade the module, you have to redo the changes every time.
Ideally, this would be two options in the settings page: which currency is the default currency, and whether to show the currency selection box or not.
Comment #4
fibie commentedThank you for your comments and for a great module.
I agree it would be best if these options were built in to the module for upgrade-ability so will add this as a feature request,
Thanks :)
Comment #5
kbahey commentedThe other option I mentioned, which does not modify the module's code, is using hook_form_alter() in a separate module to modify the currency and make it hidden. It is a bit more work, but avoids changing the source of the module.
Comment #6
jbomb commentedHere's a patch that adds those two fields
Comment #7
jbomb commentedComment #8
kbahey commentedPlease reroll against what is in -dev.
Comment #9
jbomb commentedComment #10
jbomb commentedComment #11
kbahey commented- Please make the variable_get() as defines to be consistent.
- This is redundant
if (variable_get('donation_force_default', 0) == 1) {. No need to== 1part.- There are many places with too much inlining, such as
array_intersect_key(donation_get_currencies(), array_flip(variable_get(DONATION_CURRENCY_OPTIONS, array('USD', 'GBP')))),. Better separate that into its own function for more readability.- I presume that this patch is fully tested and working. Right?
Comment #12
jbomb commentedkbahey:
i've made the changes that you suggested in your previous comment.
In regards to testing, I have tried it out with the gateway in Simple PayPal Framework set to sandbox, and have received the expected IPN messages in the logs. I have not tested the patch in a production environment because I'm not currently supporting any sites that are accepting any currency other that USD. If you think it's necessary I'd be happy to roll it out on a test site and donate a few dollars to myself, but that's as far as I can go without peer review.
The dev snapshot looks like the project was heading towards supporting other currencies out of the box. If nothing else perhaps this patch can assist in those efforts.
Note: I didn't change the status to "needs review" because the patch doesn't include the following declaration in the currency_code field on the donation form.
I should point out that it appears that the constant DONATION_CURRENCY_TEXT is not defined.
Comment #13
kbahey commentedFails ...
Comment #14
jbomb commentedI'm sorry.
Comment #15
kbahey commentedMy mistake. My sandbox contained a patched version from earlier tries.
I applied the patch in #12, and fixed the undefined variables. Also removed the t() from variables.
The changes should be in -dev in about 8 hours from now.
Please disable then uninstall the version you have and download the new version and test it.
Comment #16
venkat-rk commentedCurrency configuration works as expected in the dev version. I haven't tested it in a live transaction, but only the configured currencies are displayed at /donate and the default currency setting also works.
This patch puts the currency configuration in the donation module instead of the simple_paypal module (there was a discussion about this - the relevant comments are: http://drupal.org/node/164807#comment-960438 and http://drupal.org/node/164807#comment-1189408), but that is a call for kbahey to take, I guess.
jbomb, thanks a ton for your patches!