Skip to content
Read For Learn
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP

How to check if Woocommerce Order number equals to post ID?

global $post;

$order = wc_get_order($post->ID);    

if(!empty($order) && $post->ID == $order->get_id()){
//do things
}

This should work. The first check is because the order with the post ID does not have to exists just as you said.

Related Posts:

  1. Plugin development: get_post_meta is not working [closed]
  2. Post meta vs separate database tables
  3. WooCommerce get Shipping Class of product from either the product id or the order after order is completed
  4. Save metabox with multiple checkbox array
  5. How to iterate through custom posts and add the title to an array
  6. How to enable users to down-vote in this simple voting counter (that uses the post meta)?
  7. product-attribute-slug-is-too-long-28-characters-max
  8. get all products of one category
  9. Woocommerce add custom button to backend order table
  10. Plugin vs Settings load order (woocommerce dependency)
  11. How do I hook a custom discount to change a WC_Order price total on WooCommerce?
  12. How can I free up the memory used by update_post_meta?
  13. Add multiple shipping rates from add_rate function with custom ID
  14. set_sale_price in WooCommerce [closed]
  15. Is there a way to list tags order by post_meta field
  16. Woocommerce – Hide a Column in Cart Table
  17. Print value of an array or variable in a payment plugin
  18. How to get orders with used coupon in WooCommerce
  19. How to update total price of completed order in woocommerce? [closed]
  20. Ordering posts by metadata
  21. $wpdb -> Batch insert from XML File?
  22. How do I change the initial quantity of a product in woocommerce?
  23. Order properties should not be accessed directly
  24. Act on user meta updated, but only once
  25. How do I add custom column to woocommerce cart?
  26. How plugins_loaded works?
  27. update post meta for checkbox in the admin when inserted in the front-end
  28. WooCommerce Conditional Tag inside plugin
  29. Custom attribute type not displaying terms in edit product – WooCommerce
  30. WooCommerce registration password field not displaying
  31. Show special field when correct shipping is chosen
  32. 403 Error when text is pasted in Custom Metabox Textarea
  33. update woocommere total value on checkout based on selected payment method
  34. how to add custom functionality after woocommerce place order button
  35. WooCommerce Admin Reports : Get custom product report based on date range
  36. Adding a brand column to WooCommerce Products
  37. Woocommerce checkout update totals with datepicker
  38. Saving value of a selection option in comment form as comment meta
  39. Add a Save Button to Custom Meta Box [duplicate]
  40. Plugin with action ‘save_post’ needs to press publish twice on order to publish
  41. Strange issue saving custom field data for a WooCommerce order
  42. PHP – Extend WordPress Woocommerce Revenue Analytics with custom field
  43. Woocommerce – Convert Delivery method into a custom field
  44. “import declarations may only appear at top level of a module” when importing WooCommerce API node module
  45. Woocommerce extend tax report with custom column
  46. How can we display product price $104 on the cart while the credit card payment method is checked?
  47. Show disclaimer with accept button before redirecting to the payment gateway website
  48. How do I apply a custom discount to individual product total prices depending on their categories on the cart and checkout pages of WooCommerce? [closed]
  49. In woocommerce cart item we can add custom text but how can i add custom link? [closed]
  50. Updating Woocommerce Settings API when WordPress Settings API saved and vise versa
  51. Can’t get woocommerce_get_price_html to work [closed]
  52. How to restrict access to image folder depending on whether product is purchased or not?
  53. How to extend WooCommerce API to show bookable product availability rules?
  54. Customize WooCommerce my account dashboard through plugin
  55. woocommerce_checkout_order_processed hook executing function twice
  56. Doubts about the use of metadata and how this can affect performance on WordPress
  57. update_post_meta not working in a loop
  58. Run Shortcode of post’s custom field in functions.php / Plugin
  59. Is there a way in which I can compare product id with the order id to display content on front end before placing the order? [closed]
  60. Woocommerce Composite Products – Add a composite product to cart programmatically via ajax [closed]
  61. Get draggable widgets on Edit Post page
  62. Change WooCommerce Email Header using custom plugin
  63. UWooCommerce – add cart discount programmatically?
  64. Remove an action by extending class and replacing it
  65. Woocommerce order empty items array
  66. How to get all product in the woo-commerce? [closed]
  67. Woocommerce inventory [closed]
  68. WooCommerce change Tax Class programmatically when Recalculating an existing Order [closed]
  69. WP nonce field checkbox prints checked=’checked’ outside input field
  70. Ajax: Populate with content from a post’s ID not working – duplicating current page html instead
  71. How to change WooCommerce loop product title HTML output in single product page and archive page
  72. Can woocommerse be used dynamically for billing from another plugin for payment processing?
  73. Sending an SMS on new order placed – WooCommerce
  74. Can we use a library under MIT license in a WooCommerce plugin?
  75. Set _regular_price 0 if empty in woocommerce product
  76. Issues Updating Post Meta with AJAX (Seems simple but cannot figure it out)
  77. WooCommerce Endpoints content
  78. How remove trashed WooCommerce orders from wc_get_orders() result?
  79. How to call code when adding WooCommerce menu items via woocommerce_account_menu_items
  80. Duplicate shipping method logic to another shipping method [closed]
  81. Custom Plugin Options Won’t Update
  82. Hide one specific woocoomerce product
  83. Woocommerce – Provide Associated Category Link for Product List Plugin [closed]
  84. Using delete_post_meta for deleting multiple selected options
  85. get_shipping_methods() return empty rate
  86. Get audio metadata on file upload
  87. Plugin can’t be activated [closed]
  88. Any way to update_post_meta with html content? It gets stripped and becomes empty
  89. Remove Meta-boxes (Yoast SEO plugin) [duplicate]
  90. Is there a way to add a link with add_post_meta?
  91. Adjust query on single
  92. Remove Products From Category
  93. want to show CMB2 metabox on woocommerce product data tab
  94. wp_schedule_single_event is set correctly but sometimes not fired
  95. Dynamic page generation upon purchase of a product
  96. Customise Grouped Product display in Woocommerce with custom column
  97. Why is $_POST empty when saving custom Meta Box?
  98. Change reminder email date to 14 days before
  99. Make a php array load faster
  100. How to make every image title equal to alt text(wordpress/woocommerce)?
Categories plugin-development Tags plugin-development, post-meta, woocommerce-offtopic
CPT Post Title Permalink: Replace “@” (or all special characters) with dash “-” instead of just removing
How to properly setup an activation hook

Recommended Hostings

Cloudways: Realize Your Website's Potential With Flexible & Affordable Hosting. 24/7/365 Support, Managed Security, Automated Backups, and 24/7 Real-time Monitoring.

FastComet: Fast SSD Hosting, Free Migration, Hack-Free Security, 24/7 Super Fast Support, 45 Day Money Back Guarantee.

Recent Added Topics

  • Bug in translation system: load_theme_textdomain() returns true, files are available and accessible but the language defaults to english
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • Get the name of the template/*html file used
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
  • How to display the description of a custom post type in the dashboard?
  • Critical error on image display
  • Copying WP data and files into new install?
  • How to determine the DirectAdmin WordPress backup date?
  • How to get list of ALL tables in the database?
© 2026 Read For Learn
  • Database
    • Oracle
    • SQL
  • algorithm
  • asp.net
  • assembly
  • binary
  • c#
  • Git
  • hex
  • HTML
  • iOS
  • language angnostic
  • math
  • matlab
  • Tips & Trick
  • Tools
  • windows
  • C
  • C++
  • Java
  • javascript
  • Python
  • R
  • Java Script
  • jQuery
  • PHP
  • WordPress