PDA

View Full Version : Subscription System: Change hard coded currency


Stubbed
01-05-2010, 08:13 PM
This isn't exactly specific for VB4, but it is what I'll be using.

Has anyone or can anyone point me in the right direction for changing the hard coded currency for the subscription system? This only has to be PayPal if that makes life easier, and can replace one of the existing currencies.

Cheers;

--------------- Added 07 Jan 2010 at 10:42 ---------------

I got bored and figured this out.

Here are the instructions for adding a new currency to PayPal for anyone else's benefit:
First up, you need to find out the currency code for what you want to add. Generally you would already know this, but if you don't, go here: http://www.xe.com/ - I need New Zealand Dollars, so mine is NZD. Substitute NZD in the following code to what ever it is that you need.
open forumroot/admincp/subscriptions.php and make the following changes
Change line 214 from:
print_table_header($vbphrase['cost'], 10);to
print_table_header($vbphrase['cost'], 11);Just the 11 on the end
Under line 216, add the following:
$vbphrase['nz_dollars'],The whole lot should look like this:
print_cells_row(array(
$vbphrase['nz_dollars'],
$vbphrase['us_dollars'],The 'nz_dollars' bit is a phrase name. Change that to what ever you want, but remember it for later.
Under line 232, add the following:
$nzd = '<input type="text" class="bginput" name="sub[time][' . $i . '][cost][nzd]" dir="' . $direction . '" tabindex="1" size="7" value="' . number_format($sub_occurence['cost']['nzd'], 2, '.', '') . '" />';The whole lot should look like this:
foreach ($sub['cost'] AS $i => $sub_occurence)
{
$nzd = '<input type="text" class="bginput" name="sub[time][' . $i . '][cost][nzd]" dir="' . $direction . '" tabindex="1" size="7" value="' . number_format($sub_occurence['cost']['nzd'], 2, '.', '') . '" />';
$usd = '<input type="text" class="bginput" name="sub[time][' . $i . '][cost][usd]" dir="' . $direction . '" tabindex="1" size="7" value="' . number_format($sub_occurence['cost']['usd'], 2, '.', '') . '" />';Again, substituting nzd for what ever you're using.
Change line 247 from:
print_cells_row(array($usd, $gbp, $eur, $aud, $cad, $length, $recurring, $ccbill, $twocheckout, $options));to
print_cells_row(array($nzd, $usd, $gbp, $eur, $aud, $cad, $length, $recurring, $ccbill, $twocheckout, $options));
Change line 250 from:
print_submit_row(iif($_REQUEST['do'] == 'add', $vbphrase['save'], $vbphrase['update']), '_default_', 10);to
print_submit_row(iif($_REQUEST['do'] == 'add', $vbphrase['save'], $vbphrase['update']), '_default_', 11);Just the 11 on the end
Under line 1354, add the following:
'nzd' => $vbphrase['nz_dollars'],The whole lot should look like this:
print_select_row($vbphrase['currency'], 'currency', array(
'' => $vbphrase['all_currency'],
'nzd' => $vbphrase['nz_dollars'],
'usd' => $vbphrase['us_dollars'],
Under line 1415, add the following:
'nzd' => $vbphrase['nz_dollars'],The whole lot should look like this:
print_select_row($vbphrase['currency'], 'currency', array(
'' => $vbphrase['all_currency'],
'nzd' => $vbphrase['nz_dollars'],
'usd' => $vbphrase['us_dollars'],
open forumroot/includes/class_paid_subscription.php and make the following changes (Thanks to this post (https://vborg.vbsupport.ru/showpost.php?p=2134124&postcount=5))
Under line 182, add the following:
'nzd' => 'NZ$',The whole lot should look like this:
var $_CURRENCYSYMBOLS = array(
'nzd' => 'NZ$',
'usd' => 'US$',
The 'NZ$' bit is how you want your currency to be displayed.
We need to run an SQL query to update the PayPal Payment API. Do this in the VB Admin control panel or phpMyAdmin or what ever. Remember to put in your table prefix in front of `paymentapi` if you have one:
UPDATE `paymentapi` SET `currency` = 'nzd,usd,gbp,eur,aud,cad' WHERE `paymentapi`.`paymentapiid` =1 LIMIT 1 ;
Now you need to add a new phrase for your currency.
Login to your VB Admin CP > Languages & Phrases > Phrase Manager > Add New Phrase
'Varname' has to be what ever you put above. In my example I used "nz_dollars"
Put what ever you want in the 'Text' field. I put 'NZ Dollars'
Save You are done. You will now be able to make a new subscription using your custom currency following these instructions: http://www.vbulletin.com/docs/html/subscriptions_example

Win.

I've tested a few transactions now with no issues.

Fuhrmann
06-23-2010, 12:08 AM
Nice, nice! Thanks, this save my time.

Assopoker
12-15-2010, 03:04 AM
You are great
Its a shame that vbulletin can't set up currencies in a better way.

Stubbed
12-15-2010, 03:15 AM
Good to see people are still using this. While it's annoying that it isn't a standard feature to customise currencies, this works 100% and it's not too hard to do the above mod manually.

I've put through ~500 transactions since, had no issues with it.

Assopoker
12-15-2010, 05:31 AM
You missed something:
In /includes/class_paid_subscription.php
Add on line 183
Your :

'usd' => 'US$',

--------------- Added 1292398414 at 1292398414 ---------------

Can you tell me why

print_table_header($vbphrase['cost'], 11);
and
print_submit_row(iif($_REQUEST['do'] == 'add', $vbphrase['save'], $vbphrase['update']), '_default_', 11);
are needed?

did you tried without that change?

Stubbed
01-26-2012, 09:09 PM
I wonder where the class_paid_subscription.php piece is displayed, mine has been working since 3.8 up to 4.1.4 with out it! Good to know though. Just followed the same changes for 4.1.10 and so far appears to be working. It's almost a good thing they haven't made any changes to the subscription system in the previous 4/5 years... Heh.

The numbers on the end change the number of columns on the table in the admincp. With out it you cut off the last currency which potentially isn't an issue for most people.

Stubbed
04-28-2012, 08:09 PM
No issues again on 4.1.12

Stubbed
01-19-2013, 05:36 AM
No issues again in 4.2. Won't be trying 5 for some time :)

Stubbed
05-02-2013, 09:14 PM
So I've just installed a test vB5 install, and it appears that paid subscription currency is still hard coded, which is pretty disappointing.

I've created an improvement request in JIRA, if you use a currency outside of the standard, or if you think it's a bit silly this isn't in there by default, please head over and give it a vote: http://tracker.vbulletin.com/browse/VBV-9482

Stubbed
10-27-2013, 10:46 PM
Not surprisingly this same MOD worked on VB4.2.2.

Anyone still using this - Please vote for it to be included by default in VB5 (http://tracker.vbulletin.com/browse/VBV-9482).

bollman
12-06-2013, 06:16 PM
We've just installed this and it all works fine, except the value in our local currency (SEK, or Swedish Krona) is not displayed in the text field. If I enter a number and save, the next time I look at the subscription, the value is 0 (zero), but if I look in the database:
a:1:{i:0;a:6:{s:4:"cost";a:6:{s:3:"sek";s:4:"5.00";s:3:"usd";s:4:"0.00";s:3:"gbp";s:4:"0.00";s:3:"eur";s:4:"0.00";s:3:"aud";s:4:"0.00";s:3:"cad";s:4:"0.00";}s:6:"length";i:4;s:5:"units";s:1:"D";s:11:"ccbillsubid";s:0:"";s:18:"twocheckout_prodid";s:0:"";s:9:"recurring";i:0;}}
Which looks correct to me, at least :)
I have double and triple checked the edits in the php files, but can't see anything wrong there.
We're on 4.2.2 (brand new install, we're moving from phpBB).

Stubbed
12-06-2013, 09:12 PM
Did you do the database changes? If so, can you post up the contents of your forumroot/admincp/subscriptions.php file? Maybe in a private pastebin.