Log in

View Full Version : Give promocode when buy item?


dulop
09-12-2012, 02:02 AM
Hello!
There is a way to give a promocode to the users, when they buy an item?

Thanks! :D

Hall of Famer
09-14-2012, 02:13 AM
Well you can take a look at the class file class_promocode.php, it explains how to use the promocode class.

dulop
09-19-2012, 08:29 PM
I dont know how to give a promocode when a user buy an item :s

Hall of Famer
09-19-2012, 09:41 PM
Of course I know you dont know, thats why I told you to look at promocode class file and read the comments in it. I dont really have time to work on a custom script for anyone at this point, busy with school and Mys v1.3.2 at the moment(I will help with newbie problems such as installing/configuring the site though).

dulop
09-28-2012, 12:33 AM
Ah ok, sorry! no problem, dont worry ^^
And thanks for reply!

dulop
02-02-2013, 05:42 AM
i've seeing the files and i made this:

function items_milagros($item, $adopt){
$codigopromo = $adopts->select("items_functions", array(), "code")->fetchObject();
$mtitle = "Has ganado un logro!";
$mtext = "Felicitaciones! Has recibido una recompenza. El código es el siguiente:{$codigopromo} . Puedes usarlo en la página de promos. Para saber como usarlo hay una guÃ*a correspondiente.";

$date = date('Y-m-d');
$GLOBALS['adopts']->insert("messages", array("id" => NULL, "fromuser" => "SYSTEM", "touser" => $owner, "status" => "unread", "datesent" => $date, "messagetitle" => $mtitle, "messagetext" => $mtext));

$row = $GLOBALS['adopts']->select("users", array(), "username='{$owner}'")->fetchObject();

$newmessagenotify=$row->newmessagenotify;
$email=$row->email;

if($newmessagenotify == 1) {
// We are sending this user an email about the new message...
$systememail = grabanysetting("systememail"); // QUERYPROBLEM - we should get the settings at the beginning so we never need to call for them after that.
$headers = "From: {$systememail}";
$site_name = grabanysetting("sitename"); // QUERYPROBLEM - see, two queries for this message alone.
$message = "Hello {$owner};\n\nYou have received a new Private Message from SYSTEM at {$site_name} with the title {$mtitle}.\n
You can read this message at: http://www.".constant("DOMAIN").constant("SCRIPTPATH")."/messages.php\n
Thank You. The {$site_name} team.";

mail($email, $site_name." - You Have Received a Reward", $message, $headers);
}

$note = "Has conseguido un código promo!";
return $note;
}

Its a new function. I want that when i use a item with this function, the system send me a pm, giving me a promocode.

But doesn't work. Any idea? when i use the item, the screen goes blank.
Thank you