Log in

View Full Version : Another multi-currency question.


Tequila
02-02-2011, 04:15 PM
I want to use a secondary currency for 'donor' adoptables. All users will have 10 of these available for a taste of donor appeal.

Thing is the currency selected for the adoptable purchase is the dollar amount and not the gem amount.

Where in the files would I have to edit for this to work?

Tony
02-02-2011, 04:35 PM
Are you using a previously installed addon made by someone for the shopping system? I would need the code.

Tequila
02-02-2011, 04:39 PM
Are you using a previously installed addon made by someone for the shopping system? I would need the code.
I'm using the 1.1.4 release as the base for my site, it has a shop included for adoptables. Items on the other hand...

Tony
02-02-2011, 04:41 PM
Okay, I'll download 1.1.4 and take a look.

PTGigi
02-02-2011, 04:47 PM
I could try to sort through my code and help you out ^-^" *is not the neatest person* Since I have 6 cash types it shouldn't be too hard XD

But I believe I only had to modify the admin, doadopt, nadopt, cash, mycash, and adopt pages.

Tony
02-02-2011, 04:54 PM
There's only one type of currency.
To add the new currency called 'donor', go to admin.php to edit that first, then do some of the minor chages required in nadopts.php and finish off by editing adopt.php/doadopt.php to your liking.

Oh and edit the mycash page to show it.

Do you need step by step instructions? I'm assuming you know php. :D

Tequila
02-02-2011, 04:54 PM
I could try to sort through my code and help you out ^-^" *is not the neatest person* Since I have 6 cash types it shouldn't be too hard XD

But I believe I only had to modify the admin, doadopt, nadopt, cash, mycash, and adopt pages.
I've already messed with a few, but I wouldn't mind some small help. :)

PTGigi
02-02-2011, 05:34 PM
Alright let's hope I don't fail and forget something XD I didn't know what you were using for cash so I just used $cash2 for everything X3 Change as you like :meow:

Admin.php should read like this for the cash:
<p><strong>Adoptables Pricing Settings:</strong></p>
<p>This section allows you to set if you want to enable pricing for this adoptable. Please either disable this option or enter a positive number here.. </p>
<p><strong>
<input name='pricestatus' type='checkbox' id='pricestatus' value='enabled'>
</strong>Set a price for this adoptable</p>
<p>You can now decide how much money to charge for this particular adoptable:</p>
<input name='pricevalue' type='text' id='pricevalue' size='10' maxlength='10'>Cash 1<br>
<input name='pricevalue2' type='text' id='pricevalue2' size='10' maxlength='10'>Cash 2<br>
<p>
The cash check in doadopt should read:
// Now we determine if the user has enough cash left to purchase an adoptable, if its price status is enabled.

$pris = getpricestatus($id);
$priv = getpricevalue($id);
$priv2 = getpricevalue2($id);
$mycash = getcash($loggedinname);
$mycash2 = getcash2($loggedinname);

$cashleft = $mycash - $priv;
$casj2left = $mycash2 - $priv;

if($cashleft < 0 or $cash2left < 0){
$article_title = $name." cannot be adopted";
$article_content = "It appears that you do not have enough money to acquire this adoptable, please come back later.";
}
And just a couple lines below that should read:
//Next, the user's lost an amount of money equal to the adoptable's price value.
$query = "UPDATE ".$prefix."users SET dollar='".$cashleft."' WHERE username='".$loggedinname."'";
mysql_query($query);
$query = "UPDATE ".$prefix."users SET cash2='".$cash2left."' WHERE username='".$loggedinname."'";
mysql_query($query);And in functions you need to add:
function getcash2($loggedinname){

include("config.php");

//First we see if we are logged in or not

$loginstatus = logincheck();
$isloggedin = $loginstatus[loginstatus];
$loggedinname = $loginstatus[username];

$query = "SELECT * FROM ".$prefix."users WHERE username = '$loggedinname'";
$result = @mysql_query($query);
$num = @mysql_numrows($result);

//Loop out code
$i=0;
while ($i < 1) {

$cash2=@mysql_result($result,$i,"cash2");

$i++;
}

return $cash2;

}
And

function getpricevalue2($aid){

include("config.php");

//This function retrieves an adoptable's price from sql database.

$pricestatus = "no";

$query = "SELECT * FROM ".$prefix."adoptables WHERE id='$aid'";
$result = mysql_query($query);
$num = mysql_numrows($result);

//Loop out code
$i=0;
while ($i < 1) {

$pricestatus=@mysql_result($result,$i,"pricestatus");
$pricevalue2=@mysql_result($result,$i,"pricevalue2");
$i++;
}

if($pricestatus == "enabled"){
$priceval2 = $pricevalue2;
}
else{
$priceval2 = 0;
}

return $priceval2;

}
And I'm going to have to double check those other files in a bit, I have to eat dinner soon. D:

EDIT: Durr forgot nadopt XD Give me a minute and I'll have that up XD

EDIT2:

nadopt.php: Find the 'pricestats = $_Post" part and replace with this:
$pricestatus = $_POST["pricestatus"];
$pricestatus = secure($pricestatus);

$pricevalue = $_POST["pricevalue"];
$pricevalue = secure($pricevalue);

$pricevalue2 = $_POST["pricevalue2"];
$pricevalue2 = secure($pricevalue2);

Tequila
02-04-2011, 09:11 PM
Well that works so far. Now it removes all currencies...

Hm...

PTGigi
02-04-2011, 09:18 PM
Aw D: I don't recall that happening with me O.o

Tequila
02-04-2011, 10:00 PM
It's all right, that's why I'm running a beta site first.