Remove return;
from your code, which is prematurely exiting the function before the following two lines can be executed; that is why the status is not changed.
function my_change_status_function () {
global $post;
$ordernumber = get_post_meta( $post->ID, 'order_number', true );
$audit_status = get_post_meta( $post->ID, 'audit_status', true );
if ( $audit_status == 'Complete' ) {
$order = new WC_Order( $ordernumber );
$order->update_status( 'completed' );
}
}
add_action( 'save_post_audits', 'my_change_status_function' );
Related Posts:
- How to show link to product in custom fields?
- importing third party json feed as custom post type [closed]
- how to get posts by custom post type then display Custom fields?
- Exclude a term of a taxonomy with a custom post type in a search
- WP Rest API Querying Custom Posts by ACF fields
- Meta Query “IN” doesn’t work with ACF checkbox filter
- Insert slider (Custom Post Type) into pages
- get terms that have post with custom post type between 2 values
- How to set custom post type as post title to avoid ‘Auto Draft’
- Query current and future events, ordered by begin date
- Change message given when deleting post from custom post type
- Building an Advanced Search (text, tags, category, custom fields) – Getting the wrong SQL query
- Linking three taxonomies with ACF
- Query Custom Post Types by date (custom field) range
- How to replace custom post type slug with an ACF value?
- Problem adding column to WC Subscription [closed]
- Remove duplicated values from a loop
- How to retrieve category NAME instead of ID in a function with a taxonomy custom field?
- “add_post_type_support” with Custom Post Type & ACF
- Custom Post type and Custom Field WP_Query
- Display multiple custom post types and sort them chronological by one of their fields
- get_posts of Custom Post Type AND Custom Taxonomy
- the_content() not outputting anything (Advanced Custom Fields)
- How to add a post slug to a url?
- changing meta value and meta key of price field
- ACF Field on CPT Slug
- Custom Post Type + ACF and performance [closed]
- Meta Query Not Returning Output Despite Having Matching Values
- WooCommerce sort products by the actual product width(not the shipping width)
- Hide a widget inside a div on specific type of post
- Retrieve custom field from Contact Form 7 [closed]
- Allow add new post access to custom post but not wp post for some role
- The loop seems stuck to a single (now deleted) post
- Multiple Frontend Filters Using Advanced Custom Fields
- Displaying custom field according to date
- How to set the seo title tag on a page by page basis?
- How to add/edit advanced custom fields on custom post type’s WordPress REST API?
- Sort a custom post with ACF: Date Picker & Display Featured!
- Custom Post Type page sorts differently on different environments
- Postname on unique permalink structure appends “-2” for a custom post type. How can I get this to stop happening?
- Custome fields not displayed
- Create short URL with auto 301 redirect
- Why is wp api returning old acf values?
- Copy order items with metadata between orders – Woocommerce
- get custom post type value in header.php [closed]
- posttype and custom fields on multisite
- How do I get_the_postID() for a custom post that uses ACF repeater field?
- Update Post Status On Woocommerce Payment Complete
- CPT as Product in WooCommerce
- Group by custom field value (start and end times)
- Custom post types, disable fields
- Change permalink for custom_post_type using custom_post_meta (woocommerce)
- wp-includes does not contain a feed template
- Excerpt length: get first paragraph
- Fetch data from two custom post types and create multidimensional array for output to html table
- Having a repeating custom field in admin custom post type, what I’d go better with, for DB’s sake? ACF repeater or query a different post type?
- Query filter by value in meta_value array
- Show Post Revisions on front-end
- count & sum the value of custom field of the author post in dynamic posts
- How to show Custom Post Type – Case Study using Shortcode & ACF
- Orderby custom fields is not working
- Custom post ID & display information related to this ID
- Expire post to draft by date-picker custom field
- Display a Custom Post Type with Advanced Custom Fields on Homepage
- Filter result of Custom Post Type using meta_query with ACF
- Same custom post type with different ACF
- Custom sorting in post columns by ACF Pro Select Field
- What’s the best way to do this: inquiry/ticket system?
- WP_Query not using custom taxonomy categories on custom post type
- How would i insert a value of custom field from Advaced Custom Field into shortcode generated by Gravity Forms [closed]
- Auto generate excerpt from ACF field on a CPT that does not support excerpt or content
- ‘Simple’ Reservation System
- Subpages URLs for Custom Post Type
- Custom post type not pulling CSS
- Button link display in shortcodes using custom field in ACF
- How do I link to a dynamic ACF button from a Custom Post type?
- Taxonomy shows up twice on Custom Post Type
- How to hide sub fields in a field group and also the entire field group if the answer selected is “no”
- add action save post type and update post meta woocommerce
- In the admin, how can you list thumbnails instead of titles for a custom post type?
- Looping through image object using ACF and CPT UI [SOLVED]
- woocommerce post_type conflict with existing post type
- WordPress page not showing up – replaced with last 10 posts?
- Custom permalink rewrite rules – how do I fix this?
- Best way to have one product in both rental and sale parent category
- How do I display specific custom posts, and how do I edit a post’s singular page?
- Automatically convert standard posts with custom fields to custom post types
- Showing custom post user wise with different color in wordpress
- Submit and edit font end custom post type
- How to make a custom search template for custom taxonomy?
- Making my custom column sortable
- Filter Content on all Post Types
- Get month and day from a Date Picker custom field
- Advanced Custom Fields – Add Field to Specific Page [closed]
- Custom Search Template for Custom Post Types
- Modifying and Displaying URL’s in a Post Template using parse_url
- How to manage a bookstore
- WordPress Loop trouble with ACF [closed]
- Is it possible to specify a time interval (from, to) in ACF with date picker, or other custom field?
- Display ACF object field data using Elementor Custom Query