truong12a62009 Posted October 9, 2014 Share Posted October 9, 2014 Hello all! function mincoding_create_invoice($vars) { $from = 'myemail@gmail.com'; $subject = "mincoding_create_invoice"; $query = "select * from tblinvoices where id=" . $vars['invoiceid']; $result = mysql_query($query); if ( mysql_num_rows($result) ) { $rowInvoice = mysql_fetch_assoc($result); $query = "select * from tblorders where invoiceid=" . $vars['invoiceid']; $result2 = mysql_query($query); $rowOrder = array(); if ( mysql_num_rows($result2) ) { $rowOrder = mysql_fetch_assoc($result2); } if (isset($rowInvoice['id']) && isset($rowOrder['id'])) { $external_client_id = $rowOrder['userid']; $date = $rowOrder['date']; $contact_id = $rowOrder['contact_id']; $invoice_id = $rowInvoice['id']; $amount = $rowOrder['amount']; $paymentmethod = $rowOrder['paymentmethod']; $status = $rowOrder['status']; $paymentstatus = $rowOrder['status']; $order_id = $rowOrder['id']; $message = "Invoice created with information:" . "<br/>" . "Invoice ID: $invoice_id<br/>" . "Order ID: $order_id<br/>" . "Order Amount: $amount<br/>" . "Payment Status: $paymentstatus<br/>" . "<br/>"; $message = wordwrap($message, 70); mail("myemail@gmail.com",$subject,$message,"From: $from\n"); } } } add_hook("InvoiceCreated",10000,"mincoding_create_invoice"); i use this code to get order created with invoice information but i can't get order id when run this code. it seems query orders table return no result is there anyone know this problem? pls help me! 0 Quote Link to comment Share on other sites More sharing options...
mbit Posted October 9, 2014 Share Posted October 9, 2014 Keep it simple? Try something like this: $query = full_query("SELECT tblorders.*, tblinvoices.status AS paymentstatus FROM tblorders JOIN tblinvoices ON tblinvoices.id = tblorders.invoiceid WHERE tblorders.invoiceid=". $vars['invoiceid']); $data = mysql_fetch_array($query); $external_client_id = $data['userid']; $date = $data['date']; $contact_id = $data['contactid']; $invoice_id = $data['invoiceid']; $amount = $data['amount']; $paymentmethod = $data['paymentmethod']; $paymentstatus = $data['paymentstatus']; $order_id = $data['id']; // your mailing stuff 0 Quote Link to comment Share on other sites More sharing options...
truong12a62009 Posted October 10, 2014 Author Share Posted October 10, 2014 thank you, but it's not working still can't get 0 Quote Link to comment Share on other sites More sharing options...
mbit Posted October 10, 2014 Share Posted October 10, 2014 Strange...i can confirm - sometimes it works and sometimes it returns nothing like the hook fires before there's any data on the order in the tblorders table. Support should take a look at this 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.