Jump to content

Can't Get Order ID


Recommended Posts

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");




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!

Link to comment
Share on other sites

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

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated