0

When I'm looking at a WC_Order object, I can see that it has both an id as well as an order_key. I have tried to find out what the order_key is, but there is almost no documentation about it that I can find. Could anyone explain what it is?

I would also like to know why both that and the id exists. Is it better to use one over the other in some cases?

Community
  • 1
  • 1
Hannes Hultergård
  • 1,157
  • 1
  • 11
  • 33
  • 1
    `order_id` was probably set for private class use and not necessarily to be used by developers. `id` and `order_id` are most likely the same number. You shouldn't have to choose. You should use `$order->get_id()`, where `$order` is an instance of the WC_Order Class object. – disinfor Dec 02 '21 at 23:46
  • order_key is unique key when you place an order. Helps with payment methods , tracking orders, gtags, social tags etc. – Snuffy Dec 03 '21 at 07:25

0 Answers0