Zen Cart Logo
Forums / General Questions / Where is orders_id created.

Where is orders_id created.

Views: 592

Results 1 to 5 of 5
10 Apr 2012, 7:31 PM
#1
rliddle avatar

rliddle

New Zenner

Join Date:
Apr 2009
Posts:
50
Plugin Contributions:
0

Where is orders_id created.

We are trying to do create a script that keys off the order id. So my question is what script in Zen Cart creates the Order Id. --- orders_id in the _orders table

10 Apr 2012, 8:00 PM
#2
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Where is orders_id created.

The database generates the orders_id value when the new record is inserted as part of the create() method in the order class.
The smartest way to extend that is to hook the NOTIFY_ORDER_DURING_CREATE_ADDED_ORDER_HEADER notifier point by adding your own custom observer class to take the passed array of data (containing the new order id and other info) and use it as part of your custom code requirements. That way you don't need to touch the order class PHP file AT ALL.

11 Apr 2012, 6:22 AM
#3
rodg avatar

rodg

Deceased

Join Date:
Jan 2007
Location:
Australia
Posts:
6,263
Plugin Contributions:
4

Re: Where is orders_id created.

DrByte:

The database generates the orders_id value when the new record is inserted as part of the create() method in the order class.
The smartest way to extend that is to hook the NOTIFY_ORDER_DURING_CREATE_ADDED_ORDER_HEADER notifier point by adding your own custom observer class to take the passed array of data (containing the new order id and other info) and use it as part of your custom code requirements. That way you don't need to touch the order class PHP file AT ALL.

Forgive me if I appear to be slack/lazy for asking, but are there any tutorials available that provides more details into how to add an 'observer class'?
For various reasons, I've never had need to look into this aspect of zencart before now, but I'm currently working on a couple of things whereby if I'm not mistaken this could make things a whole lot easier for me.

Thanks
Rod

11 Apr 2012, 6:34 AM
#4
gilby avatar

gilby

Totally Zenned

Join Date:
Aug 2005
Location:
Vic, Oz
Posts:
1,816
Plugin Contributions:
0

Re: Where is orders_id created.

RodG:

Forgive me if I appear to be slack/lazy for asking, but are there any tutorials available that provides more details into how to add an 'observer class'?
For various reasons, I've never had need to look into this aspect of zencart before now, but I'm currently working on a couple of things whereby if I'm not mistaken this could make things a whole lot easier for me.

Thanks
Rod

http://www.zen-cart.com/forum/showthread.php?t=32443

11 Apr 2012, 12:38 PM
#5
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Where is orders_id created.

Further to gilby's good suggestion, there are wiki articles, and lots of current version addons use them too. And I've posted many complete working examples in answers to various forum posts.