First thing is to grab the last order ID, you can do it with a simple WP_Query
$args = array('post_type'=>'product',
'posts_per_page'=>1,
'orderby'=>'ID',
'orderby'=>'DESC');
$query= WP_Query($args);
As this will only give only one result, you don’t need to loop the result,
$order_id= $query->posts[0]->ID;
Now, you can reach the order data,
$order = WC_Order($order_id);
You can use the object with any woocommerce order related functions.
Hope it helps.
Related Posts:
- Make WooCommerce pages accessible for logged in users only
- How to update user role without logout
- get_userdata by username
- Authenticate with a Rails app?
- Add user data to table when user is created?
- How to add a user profile page to frontend?
- WordPress Login Customization for External Authentication
- Allow unfiltered HTML for not logged in users when saving a post
- WordPress REST Api: update user
- Get usermeta info from sql query
- Is there a way to call via javascript if a user is logged-in on a static html file?
- How can I display Only the first Array/Object?
- Custom registration fields not appearing in user info
- hide woo commerce dashboard status and reports from woo commerce from specific users but display to other users
- WordPress C# User Login
- Unable to retrieve Users (Not logged in) through WP Rest API
- Editor can create any new user except administrator
- Confirmation required on email change
- get_current_user_id() returns 0?
- List users by last name in WP_User_Query
- WP/WooCommerce REST API cart/checkout/order [closed]
- How to redirect a specific user after log-in?
- How to Prevent deleting user accounts in WordPress Back-end?
- Upload gravatar in WP profile?
- How to stop a user from updating the post date
- Recover the user that have been deleted
- determining if the user is logged in
- Adding a photo to each WP user
- How to check that if current user (ID) has posts or not
- How to get the Role Name of the current user? (WordPress)
- how to get recent registered author id?
- set_role has no effect
- Get users only if Gravatar is specified
- WordPress to use Drupal users’ credentials
- How do I list in the backend all users that were assigned to a custom role?
- Send Email to Users after Deleting Account
- Suddenly all emails in User have [email protected]
- *wpupdateuser* user_login in my WordPress database
- Updating user meta
- Changing a username
- Change the user_login at registration
- Are User Levels Still Currently Used?
- Delete users from multisite after they have not logged in for a set amount of time?
- Where is the information about the authors for articles stored?
- Restrict access of admin uploads to certain logged-in users?
- Woocommerce REST API allow normal users make an order
- Find user by nicename and open profile
- Using Cloudflare caching on wordpress with front-end user logins
- Redirect user after successful email change
- get_user_meta an ID for multiple functions
- Custom default filtering in the user admin panel disables the other sortable columns
- Reset Password policy
- Which function is called after update any field of user from any where of the site
- Register user when after filling contact form
- Custom Comment Notifications Fire on each Page Load
- The Simple and Correct Way to Add User Meta
- Export Users and their Advanced Custom Fields
- Hide hour from displaying when using user_registered
- How to copy user_nicename value into user_login
- How to check User Role and redirect to specific page according to Role when login in WordPress?
- Users – remove ‘send password’ checkbox
- Send email to all registered users [closed]
- Is it possible to create new user from external form using REST API?
- Send clear password via mail
- How to get users by specific ID’s WordPress
- Didn’t get array of users like in delete action WPList table in users tab
- Cannot Update user meta in custom field
- How to programmatically read the plan text password when user register?
- Check if user is logged in via JS? [duplicate]
- I want to change my user name
- Unique password to access a section site
- Page for logged in user to Edit/Delete their own content?
- Cannot Modify Header Info Error on updating User Profile
- Is it possible to build social networking website using WordPress?
- Easiest way to create an user across several websites
- woocommerce REST api on the website’s front-end
- How to change default username field after login
- Post Taxonomy Value get from User Field Value
- Iterating users while user iteration is suppressed
- email address non required
- In admin manage users page, how can I stop users with certain privileges from editing users with other privileges?
- user and usermeta table not found
- How to programatically create a WooCommerce downloadable product?
- UserMeta Changes Meta Value for Post ID
- Users set passwords but cannot login
- Subscriber role – blank page
- Set user role on registration so can upload file to own media library area
- Ordering list of users by last name and then by first name
- Separate Profiles for Users
- User “none” role
- Migrating Users along with their password
- show count author post today
- Limit user access to installing/configuring a plugin?
- Create users from frontend without password
- How to get user contact info
- Why does a super admin on multi site get a rest_user_invalid_id error code when requesting user details through REST?
- How can I list users by date in an array in meta_value?
- Email Subscribe for Downloads in WordPress
- Cant edit profile from frontend
- Can I provide a user’s user_ID to them and can it also be searchable in a member’s directory