After a great deal of time and trial and error I am stumped with this basic php variable handling and I would be grateful for some help.
To cut a long story short I am playing with the cod module (although I want to implement the hacks in another module that I can only test live).
I have declared the new variable ($Qb_order_no) I want to use:
and have set it here:PHP Code:
class cod {
var $code, $title, $description, $enabled, $Qb_order_no;
I see the $this->Qb_order_no as being set correctly (an integer) at the bottom of the order confirmation page.PHP Code:
function process_button() {
global $order, $db;
$gv_query= "insert into qb_zhenit (pedido) values ('".urlencode(serialize($order))."')";//creates new record for this order in table qb_zhenit
$gv = $db->Execute($gv_query);
$this->Qb_order_no = $db->Insert_ID();
echo 'fn Process Button: $this->Qb_order_no='.$this->Qb_order_no.'<br />';
// return false;
}
Then I want to use this variable again here:
Here $this->Qb_order_no is empty.PHP Code:
function after_process() {
global $order, $db, $insert_id;
echo 'fn After Process: $this->Qb_order_no='.$this->Qb_order_no.'<br />';
$query_add_order_id = "UPDATE qb_zhenit SET orders_id=$insert_id WHERE id = $this->Qb_order_no";
echo '$query_add_order_id ='.$query_add_order_id.'<br />';
$db->Execute($query_add_order_id);
//return false;
}
If I set
$this->Qb_order_no ='999'; in the constructor,
then I find that:
in process_button it has the correct value,
but in after_process it has '999'
which looks like after_process is evaluated before process_button.
No doubt this is trivial, but I am stuck...
Bookmarks