I have very weird problem: I've created simple Wordpress based store. I sell e-books and send them via email. I use online payments and have plugin to work with them. It have build-in gateway in php file. I want to inject my code to this script to automatize selling. It looks like this:
<?php
//1. Get payment info from payment service via $_POST
//2. Chceck all hashes etc.
//3. Get status to variable e.g. $status
if ($status == 99)//everything is ok
{
$order_id = $_POST["no_of_transaction"];
log_to_file("Yeah i am workig. id =".$order_id."with status ".$status);
include $_SERVER["DOCUMENT_ROOT"]."/sell_stuff.php";
log_to_file("Yeah i am still workig");
}
?>
sell_stuff.php:
<?php
log_to_file("Hello i am in sending script!");
//i assume that $order_id is still visible
$order = mysql_fetch_assoc(mysql_query("SELECT * FROM order where id=".$order_id));
$mail->to = $order['email'];
$mail->attachment = "/upload/pdf/".$order['book'].'.pdf';
$mail->send();
?>
And this method not working at all :( I've tried to change include to require and use ABSPATH instead of $_SERVER["DOCUMENT_ROOT"] but it still fails. Last thing logged in log file is ""Yeah i am workig. id= xxx with status = 99". I've created test.php file like this:
<?php
echo "Yeah i am workig";
$oder_id = 100; //my own order
include $_SERVER["DOCUMENT_ROOT"]."/sell_stuff.php";
echo "Yeah i am still workig";
?>
... and when I run this via www.mystore.com/test.php it's work perfectly. It logging to file "Hello i am in sending script!" and all other stuff. I dont know where i make mistake :(