The order notes are saved as post comments, so you can use the WordPress function get_comments()
to get the last note:
$args = array(
'post_id' => $order_id,
'orderby' => 'comment_ID',
'order' => 'DESC',
'approve' => 'approve',
'type' => 'order_note',
'number' => 1
);
remove_filter( 'comments_clauses', array( 'WC_Comments', 'exclude_order_comments' ), 10, 1 );
$notes = get_comments( $args );
add_filter( 'comments_clauses', array( 'WC_Comments', 'exclude_order_comments' ), 10, 1 );
By default Woocommerce excludes order notes when calling the get_comments function. To prevent this, you have to remove the filter, call get_comments()
and add the filter again. I copied this code from the function WC_Meta_Box_Order_Notes::output()
in wp-content/plugins/woocommerce/includes/admin/meta-boxes/class-wc-meta-box-order-notes.php and added “number”, so you just get the last note.
Related Posts:
- Woocommerce change tax rate programmaticly
- Create WooCommerce new order with specific ID
- Woocommerce: Prevent sending of email when order is “Completed”
- how to do a processing Orders into Complete after x Minutes or x hour in WooCommerce [closed]
- change wp_login url and redirect users at the same time
- WooCommerce quick checkout form? [closed]
- Can’t show most recent comment on top with wp_list_comments() for WooCommerce reviews
- WooCommerce order complete email logic
- WooCommerce orderby template disappears and not longer works on search page
- How to get woocommerce selected variation from order object
- Send email notifications to a defined email address depending if a product in order has a specific TAG [closed]
- Cancelled orders move to Trash automatically in Woocommerce – how to disable?
- how can i add an additional action into woocommerce admin order page through my plugin?
- Create a regular post for every WooCommerce order
- How to alter taxes amounts when updating an order
- WordPress woocommerce new order email not working
- Custom Email via Hook only for completed order
- Access custom meta_data in processing order email
- Sort products by Sale price and stock status
- Create order actions from custom fields woocommerce
- How to sort products by price ASC and place all no price products to the end? (Woocommerce)
- Custom pagination permalink structure Product page
- How to find which last line executed in wordpress?
- how can my customers view their purchased products history like an invoice in a specific page on WordPress
- Hide review form if user has left a comment
- Change the customer’s name to a link on an order management page
- How to save one API response to WooCommerce order meta data
- Add button linked to single product page on order detail page
- Multiple sorting criteries (order by)
- Woocommerce order_complete email dont send after changing order status via sql
- Conditional email recipient based off Shipping Method [closed]
- Product atributes in title of order (not in description)
- WooCommerce: Order Details Table > Add Product Meta
- Woocommerce admin order email customize – remove product short description
- Critical error on woocommerce checkout page
- Is it possible to add custom fields to a WooCommerce attribute term? [closed]
- WooCommerce ‘all’ orders no longer being displayed – how may I debug/fix [closed]
- Add custom variable to cart content [closed]
- Woocommerce My Account Endpoint – how to get ID parameter from URL?
- Default woocommerce placeholder image
- How to add Woocomrce cart page shipping calculator to my country state list
- Button to update order status Woocommerce with WC Marketplace
- WooCommerce: display text instead of raw checkbox value email
- How we can edit variations on cart page? [closed]
- new WC_Order(); Coming Back Empty
- WooCommerce WebHook Retry
- Where is the CSS class ui-sortable-handle for WC_Admin_Taxonomies added?
- WooCommerce: “account is already registered with your email address”
- Enter name and email on the Product page and keep the input data on the Checkout page
- Separeting product from post in search result
- Woocommerce: Same gross price for different tax rates [closed]
- add shoppy.gg to woocommerce instead of add to card [closed]
- List of shipping on product page [closed]
- How to edit T&C checker text in Woocommerce checkout page? gettext?
- What is the reason for two classes storefront_woocommerce and storefront
- Get email type inside email template – order emails
- Confirm Password on checkout page not working in woocommerce 3.0.1
- Woocommerce’s add_to_cart function returns false and doesn’t add anything to the cart [closed]
- How to check woocommerce single product tag
- How to check if a product is purchased within the last 365 days before displaying something
- Adding author option to [products] woocommerce shortcode
- Colour of selected radio button seems backwards in Twenty Seventeen + Woocommerce
- How to modify WooCommerce button text in default and additional languages
- Customizing WooCommerce
- Get Post ID from attachment ID (Redirect to product page)
- Woocommerce custom taxonomy filtering
- Woocommerce product tab is not showing probably
- How to list best seller products in woocommerce
- Updating failed. The response is not a valid JSON response. Gutenberg + Woocommerce Products
- Add product image to Woocommerce downloads page
- Sharing data between filters on a snippet (user specific) for Woocommerce
- How to add custom checkboxes from loop to WooCommerce product variation options?
- Restrict product tags archive to certain users
- Woocommerce doesn’t work with theme, header missing and css messed up
- Woocommerce Product Variation – Add Price Logic
- Display related product categories by subcategory
- Order again Woocommerce inside View Order
- How to fix: “The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.” after malware cleaning
- Can’t update WooCommerce payment method title
- Set Post Thumbnail to external URL
- Custom theme woocommerce product detail page template not working
- WooCommerce related products load random posts per page
- WooCommerce: Adding a setup fee to certain products
- Woocommerce Languages Files
- How to adjust Related Page Thumb Sizes on single page?
- Adding more than one item to Woocommerce cart
- Woocommerce – get product in category with specific attribute
- How to edit the header banner in the search page in woocommerce?
- How can I display one product using WooCommerce
- How do I change the woocommerce product gallery to show all thumbnails instead of three at a time in a carousel?
- How to add a menu page for options in wordpress for user that has the role of vendor?
- Testimonials/Reviews for Products
- add custom menu in woocommerce dashboard [closed]
- Turkish Character Problem on mailing
- Override function
- How to disable schema from Wocommerce? [closed]
- Updating order meta to have a meta entry from an item in the order
- Add second price option based on payment method at cart item price
- Create WordPress account on different domain when WooCommerce order completed
- Creating a woocommerce order when a user creates an account