Add a function/filter to retrieve the order ID for a given order number
Created on | 31.01.2016 23:38 |
Resolution | FIXED |
Resolved on | 31.07.2016 19:49 |
Version | unspecified |
OS | All |
Architecture | All |
Reporter | office |
Extended Description
Request von Jan 15, 2016 from Niklas Högefjord (niklas@krokedil.se):
Hi, We have a customer using your extension Advanced Order Numbers for WooCommerce. They are also using our extension that communicates with a payment gateway for credit card payments. Do you offer a helper function in your plugin that helps us retrieve the WooCommerce order ID from an order based on the ordernumber created by your plugin? We send the ordernumber to the payment processor and would like to transform that to the order id to be able to update order status when the payment processor pings the stor after a purchase. Kind regards /Niklas Högefjord Krokedil
Our Response:
Dear Niklas,
Thank you for the request for a helper function to retrieve the order ID from a given order number. This is indeed a feature that is not yet available.
The order number is stored as a post meta called "oton_number".$type, where $type is either "ordernumber" or "invoice". So, the problem basically boils down to finding the post which has the post meta "_oton_number_ordernumber" set to a given value.
As I said, there is currently no such function implemented, but it is certainly a useful and desired feature. I have put it on our list of feature for future implementation, but I cannot give any time frame for its implementation. When we implement it, it will probably be a filter that gets passed the nrtype and the number itself.
For now, I suppose you might simply implement it using either get_posts / WP_Query to load the corresponding order and read out the id, or you can alternatively use an SQL statement to read the order ID directly from the database.
Best regards,
Reinhold