How to check if Woocommerce Order number equals to post ID?
I am facing a challenge. I need to check if Woocommerce Order Number will equal Post ID. I know that this is true like 90% of times, but I need bulletproof way to check this. See example where this is not true and Order number and Post ID do differ:
Things to consider:
- My plugin may be installed at a time where no orders are created in Woocommerce yet
- I found this occasion on wordpress multisite, but I know that there are also plugins for sequential order numbers. And there is a lot of them, so I cannot just check for existence of one or two plugins.
- I need to know this because I am developing a plugin to check payments made manually by the customers. So I know that the payment will be identified by Order Number and not by Order ID (which is always equal to Post ID)
Edit: Expected business flow of my plugin
The plugin I have developed is “offline payments” for bank account payment. So, the flow is this:
- User selects products and decides to pay for them via “Bank account” payment gateway (one of default gateways in Woocommerce)
- User will see bank account and order number to pay (In my case Order number 84)
- User will send money to given bank account, specifying the order number (In Czech this field is called “variable symbol”)
- The plugin connects to the bank via API and queries all transactions on given bank account
- What I need to decide = If payment is received with order number 84, it means that Order ID 7257 (see picture above) is paid.
In most of the sites applies that Order ID == Order Number. However here not and I need to have logic how to decide this. So far I am just thinking about adding a checkbox to the plugin…
Thanks a lot for any ideas
Leave an answer