Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Showing Order ID


Guest

Recommended Posts

Posted

I've created an upload page and I'm looking to display the order id. I tried $HTTP_GET_VARS['order_id'] and that doesn't work. I even tried just getting the order number to show up on the Checkout Success page. I got nothing. Any suggestions?

Posted

# Get the last order by this customer
$orders_query = tep_db_query("select orders_id from " . TABLE_ORDERS . " where customers_id = '" . (int)$customer_id . "' order by date_purchased desc limit 1");
$orders = tep_db_fetch_array($orders_query);

# echo the order_id
echo $orders['orders_id'];

 

Bobby

Posted

That worked great. Now, unfoltunately, I have yet another problem of similar nature. I'm calling a file from the "classes" folder to check paramets on the files uploaded. I want that file to prepend the order number to the file but the same code wont work for the class file. Any advice on that?

Posted

Why prepend it to the class filename? Why not just write the class as an abstraction layer like it's suppose to be and then initialize the class with the id??

 

It sounds like you're creating problems for yourself...

 

Bobby

Posted

You're speaking in tongues my friend. I'm shocked I've developed THIS far in php. Believe it or not, I've picked all this up just in the past week. Some of the more complex code lingo still eludes me. I'm not sure why my way is more complex, but if you have an easier way, please... enlighten me. You've been the most helpful person thusfar. What would you do instead?

Posted

Read a few tutorials online about PHP classes...they're free and plentiful! If you've picked that much up in a week you'll breeze through classes.

 

Once you get some knowledge come back and re-visit this thread...you'll see what I'm talking about.

 

Bobby

Posted
...

Why not just write the class as an abstraction layer like it's suppose to be and then initialize the class with the id??

...

 

That sounds really intimidating to somebody new to classes... but I think I'll use that in my meeting with my Manager on Tuesday. :lol:

Posted
I've created an upload page and I'm looking to display the order id.  I tried $HTTP_GET_VARS['order_id'] and that doesn't work.  I even tried just getting the order number to show up on the Checkout Success page.  I got nothing.  Any suggestions?

 

to show the ordernumber on checkout success all it takes :

 

echo TEXT_YOUR_ORDER_NUMBER . $orders['orders_id'] . '<br><br>';

Treasurer MFC

Posted

Yea, that was the first thing I thought to try. I got nothing from that.

Posted

hehehe...didn't mean to make it sound complicated but that is as simple as I can say it :)

 

OK...I have a few minutes before bed so I'll explain "abstraction" to the beginners. For the more experienced => don't give me a hard time for such a simple example :)

 

Let's say you want to make a class called "vehicle". You could write it like this:

class vehicle {
var $wheels, $doors;

function vehicle( $wheels, $doors ){
$this->wheels = $wheels;
$this->doors = doors;
} # end of vehicle class constructor

}

Now you have can initialize it however you want like this:

$truck = new vehicle(4, 2);
or 
$4_wheeler = new vehicle(4, 0);

See, they are both vehicles but the abstraction layer (the class) can be used for both of them.

 

$truck->doors is equal to 4

$4_wheeler->doors is equal to 0

 

You can have many instances of the same class and each will have its own set of properties.

 

That is simple abstraction...

 

Bobby

Posted
then you have global product notifications enabled

 

 

look for this :

 

if ($global['global_product_notifications'] != '1') {

$orders_query = tep_db_query("select orders_id from " . TABLE_ORDERS . " where customers_id = '" . (int)$customer_id . "' order by date_purchased desc limit 1");

$orders = tep_db_fetch_array($orders_query);

 

and move this :

 

$orders_query = tep_db_query("select orders_id from " . TABLE_ORDERS . " where customers_id = '" . (int)$customer_id . "' order by date_purchased desc limit 1");

$orders = tep_db_fetch_array($orders_query);

 

above this :

 

if ($global['global_product_notifications'] != '1') {

Treasurer MFC

Posted

Exactly...in this case to cover all the bases I would just use a fast query to pull the order_id. I hate to put up code that works on some stores and not others. You never know how many people will cut-n-paste code from old posts :)

 

Bobby

Posted

I read up on defining a class on the page as opposed to a remote file like you said, and I'm going to try to apply that.

 

I also found the global notification like I was told to look for and, of course, it was not turned on. I moved the line as you suggested, but now I'm thinking global notification should be on. Where do I enable it? I would think somewhere in the app top, or as an option on the backend, but I can only see it on the checkout_success page.

 

thx for all your help

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...