PDA

View Full Version : Promocode


SilverDragonTears
04-11-2012, 08:58 PM
HoF can you take a look at this really fast? I need it fixed asap as I just released a dragon that gives a reward. It adds everything blacnk in the database.

SilverDragonTears
04-11-2012, 09:21 PM
Update: Now it's adding in the info but it rewards it to system instead of the owner.

Hall of Famer
04-12-2012, 12:18 AM
umm are you trying to create a promo code that can be used for more than once?

SilverDragonTears
04-12-2012, 12:20 AM
yep I already did... It sends a message to the user saying they got a reward. Then you click and it says you get the reward. I look in the db and it's in the inventory and the owner is listed as SYSTEM.

Hall of Famer
04-12-2012, 12:23 AM
umm strange, perhaps it has something to do with the way reward is handled? I will look into that.

SilverDragonTears
04-12-2012, 12:25 AM
Thanks. I tried looking myself but I don't see anything. And the reward is already out and some people are missing out on it :(

Hall of Famer
04-12-2012, 12:27 AM
Can you take a screenshot from table prefix.promocodes(you may or may not cover the actual codes, as the codes are unique to each member anyway. Cheaters will be banned)? Id like to see if the record inserted into the table is malfunctioning. This will determine if the flaw is in admin control panel script, or the class file.

SilverDragonTears
04-12-2012, 12:31 AM
http://img1.UploadScreenshot.com/images/main/4/10116244492.png (http://www.UploadScreenshot.com/image/900441/7879367)

Hall of Famer
04-12-2012, 12:44 AM
Well yeah it indeed is not recording the user data. On 197, check if the line looks like this:


<input name='user' type='text' id='user'>

SilverDragonTears
04-12-2012, 12:46 AM
Which script?

Hall of Famer
04-12-2012, 12:51 AM
the adopt.php file in AdminCP subfolder.

SilverDragonTears
04-12-2012, 12:51 AM
No it says <p>
User:(leave blank if you want it to be available to everyone)<br>
<input name='user' type='text' id='name'>
</p>

Hall of Famer
04-12-2012, 01:43 AM
Then change it, I apologize for this. No idea why it happened as my site was working out just nicely...

SilverDragonTears
04-12-2012, 01:48 AM
Changed it and readded the promocode but there is still nothing in the user field

Hall of Famer
04-12-2012, 01:52 AM
Then it was not the cause of your problem after all, its strange how it is working on my site though. What did you enter for the user field? It should be the username, not uid.

SilverDragonTears
04-12-2012, 02:01 AM
Nothing. It says if you want it to apply to all then to leave it blank.

Hall of Famer
04-12-2012, 02:17 AM
Oh... So the promocode is working if you give it to a specific user, but not to the general public?

SilverDragonTears
04-12-2012, 02:18 AM
Yep! That's the problem

Hall of Famer
04-12-2012, 02:26 AM
I see, at this moment the promocode is not set up in a way to handle multiple users yet. However, you can make it happen by editing these:


public function __construct($code = ""){
// Fetch the database info into object property

$stmt = $GLOBALS['adopts']->select("promocodes", array(), "code ='{$code}'");
if($row = $stmt->fetchObject()){
// loop through the anonymous object created to assign properties
foreach($row as $key => $val){
// Assign properties to our promocode instance
$this->$key = $val;
}
}
else $this->message = "Promocode does not exist...<br>";
}


change to:


public function __construct($code = ""){
// Fetch the database info into object property

$stmt = $GLOBALS['adopts']->select("promocodes", array(), "code ='{$code}'");
if($row = $stmt->fetchObject()){
// loop through the anonymous object created to assign properties
foreach($row as $key => $val){
// Assign properties to our promocode instance
$this->$key = $val;
}
if(empty($this->user)) $this->user = $GLOBALS['loggedinname'];
}
else $this->message = "Promocode does not exist...<br>";
}

SilverDragonTears
04-12-2012, 02:29 AM
Sorry :/ Which script?

SilverDragonTears
04-12-2012, 02:34 AM
Edit: Ignore me. I edited the wrong script even though I knew which one was the right one O.o It works now.

PokePets
04-12-2012, 03:02 AM
I have the same problem, when I try to claim an adoptable with a promo code, the adoptable is inserted in the DB, but the owner field is empty.

Hall of Famer
04-12-2012, 03:05 AM
Oh my goodness, looks like you have a big problem here. I have to work on the design project at this moment, so I will not be able to take care of this for tonight. The promocode system at this moment is set up in a way to handle user-specific codes only though. For now just try not to worry about public promocodes, I will look into ways to fix it later.

SilverDragonTears
04-12-2012, 03:05 AM
It worked for me.... just do what HoF told me to do.

Hall of Famer
04-12-2012, 03:10 AM
Oh so it worked? Thats nice, I am not sure if I should consider this a glitch yet, but I will make sure to improve the promocode system further in Mys v1.3.2 so it can handle not only user-specific codes, but also public and multiple-user(more than one user, but not everyone).

SilverDragonTears
04-12-2012, 03:11 AM
It's not a glitch... but people will think they're able to enable all users to use it.