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:
- Plugin development: get_post_meta is not working [closed]
- Post meta vs separate database tables
- WooCommerce get Shipping Class of product from either the product id or the order after order is completed
- Save metabox with multiple checkbox array
- How to iterate through custom posts and add the title to an array
- How to enable users to down-vote in this simple voting counter (that uses the post meta)?
- get all products of one category
- Woocommerce add custom button to backend order table
- How do I hook a custom discount to change a WC_Order price total on WooCommerce?
- set_sale_price in WooCommerce [closed]
- Is there a way to list tags order by post_meta field
- Woocommerce – Hide a Column in Cart Table
- Print value of an array or variable in a payment plugin
- How to update total price of completed order in woocommerce? [closed]
- $wpdb -> Batch insert from XML File?
- How do I change the initial quantity of a product in woocommerce?
- Act on user meta updated, but only once
- update post meta for checkbox in the admin when inserted in the front-end
- Custom attribute type not displaying terms in edit product – WooCommerce
- Show special field when correct shipping is chosen
- WooCommerce Admin Reports : Get custom product report based on date range
- Adding a brand column to WooCommerce Products
- Saving value of a selection option in comment form as comment meta
- Plugin with action ‘save_post’ needs to press publish twice on order to publish
- “import declarations may only appear at top level of a module” when importing WooCommerce API node module
- Woocommerce extend tax report with custom column
- Show disclaimer with accept button before redirecting to the payment gateway website
- 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]
- Can’t get woocommerce_get_price_html to work [closed]
- How to restrict access to image folder depending on whether product is purchased or not?
- woocommerce_checkout_order_processed hook executing function twice
- Doubts about the use of metadata and how this can affect performance on WordPress
- update_post_meta not working in a loop
- Run Shortcode of post’s custom field in functions.php / Plugin
- 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]
- Get draggable widgets on Edit Post page
- Change WooCommerce Email Header using custom plugin
- UWooCommerce – add cart discount programmatically?
- Remove an action by extending class and replacing it
- Woocommerce inventory [closed]
- WooCommerce change Tax Class programmatically when Recalculating an existing Order [closed]
- WP nonce field checkbox prints checked=’checked’ outside input field
- How to change WooCommerce loop product title HTML output in single product page and archive page
- Sending an SMS on new order placed – WooCommerce
- WooCommerce Endpoints content
- How remove trashed WooCommerce orders from wc_get_orders() result?
- How to call code when adding WooCommerce menu items via woocommerce_account_menu_items
- Duplicate shipping method logic to another shipping method [closed]
- Custom Plugin Options Won’t Update
- Hide one specific woocoomerce product
- get_shipping_methods() return empty rate
- Get audio metadata on file upload
- Plugin can’t be activated [closed]
- Any way to update_post_meta with html content? It gets stripped and becomes empty
- Remove Meta-boxes (Yoast SEO plugin) [duplicate]
- Is there a way to add a link with add_post_meta?
- Adjust query on single
- wp_schedule_single_event is set correctly but sometimes not fired
- Dynamic page generation upon purchase of a product
- Change reminder email date to 14 days before
- Make a php array load faster
- How to make every image title equal to alt text(wordpress/woocommerce)?
- Pass Values in URL on WooCommerce Product Page
- Woocommerce place order update shipping price
- Condition to check previous next article post title
- product-attribute-slug-is-too-long-28-characters-max
- register_meta not showing custom post type metabox data in rest api
- “add to cart” links css class “ajax_add_to_cart” doesn’t show in woocommerce in widget sidebar
- How do I add filter with woocommerce categories?
- Getting products information, in woocommerce based on products ID
- PHPUnit Testing and woocommerce Constant
- Redirect WooCommerce checkout to cart
- “Enable Media Replace” plugin does not update serialized object in WPMeta
- WC REST API Error Handling
- Woocommerce Product finder feature on home page
- want to confirm popup with “Yes” and “No” button when user click on add to cart
- How to remove the WooCommerce Product->Category thumbnail from admin [closed]
- Woocommerce Single Product Tabs Got Duplicate
- Woocommerce product not appearing in category list page when created programatically [closed]
- Override WooCommerce files from plugin
- woocommerce add a new bulk action in the bulk actions dropdown in the orders list
- WordPress Reset password Strength set to medium
- Unexpected issue when using attachment_fields_to_edit filter
- external Integration with wordpress timeout error
- Handle changed Woocommerce function
- Making Woocommerce optimized for more than 500k products
- Displaying Custom Post Meta
- WP: adding Javascript to specific woo commerce pages
- Declaring a new woo commerce product type i get this error
- Include add_post_meta in a plugin
- How to only Load scripts on variable products page
- How to design WooCommerce-like admin tabs for plugin settings page?
- Woocommerce: block user removing cart item
- how do I find out if a placed order was deleted or trashed? [closed]
- Return custom product in ajax call loop
- WooCommerce adds a newline symbol (\n) between email recipients
- A better way of getting draft posts that has a particular post meta using get_posts function
- Allow HTML in product attributes and variation for WooCommerce
- How do I add multiple custom menu Woo-commerce my account page?
- High-Performance Order Storage conflict action `manage_shop_order_posts_custom_column`