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?
- 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]
- Issue to display Permalink (ACF Relationships in Custom Post Type )
- Auto generate excerpt from ACF field on a CPT that does not support excerpt or content
- ‘Simple’ Reservation System
- How to access repeater field of a custom field?
- Change display of product price on product show page only
- Filter posts by their related field’s custom field
- If ACF Post Object post has custom taxonomy term…
- Subpages URLs for Custom Post Type
- ACF Pro Accessing fields on a Custom Post Type
- Custom post type not pulling CSS
- Modify Publish Metabox location on CPT
- Some posts not displaying by taxonomy term
- Button link display in shortcodes using custom field in ACF
- How do I link to a dynamic ACF button from a Custom Post type?
- edit.php all post not working
- Changing default admin column sorting to an ACF Date Picker field
- ACF meta_key and meta_value break loop
- search results to show individual ACF fields from inside custom posts
- Taxonomy shows up twice on Custom Post Type
- Save_post acf data not updating category of post type
- Videos Post Type with Custom Filters
- Permalink URL connection between two custom types
- Display Specific Posts at Start of Loop
- How to display custom post type pagination buttons when processing AJAX request
- Adding specific custom fields (images) to post excerpt
- filter using custom fields
- How to hide sub fields in a field group and also the entire field group if the answer selected is “no”
- Create 3 Levels of relations with WordPress
- Wrapping an unknown amount of posts inside separate HTML Containers during WP_Query loop
- add action save post type and update post meta woocommerce
- WooCommerce – Custom related product (Spareparts)
- Convert attribute woocommerce terms (taxonomy terms) in posts of custom post type
- Show specific posts with WP_Query using ACF Post object
- WooCommerce change
- Display custom tax in “while” loop
- Autofill advanced custom field with user data
- WooThemes – Vendors / Bookings – Allow Vendors to manage resources
- Advanced search form with multiple custom fields
- Custom post type option page template
- In the admin, how can you list thumbnails instead of titles for a custom post type?
- Use output of wp_dropdown_categories($args)
- Some permalinks on Apache/localhost development setup return 404’s when set to anything other than plain permalinks
- CPT: execute code after load if parameter is set
- Looping through image object using ACF and CPT UI [SOLVED]
- Search in multiple specific post types
- Linking posts together with Advanced Custom Fields “both ways”
- How to get a custom post type archive paged when using a custom field for post sorting?
- save_post affect creation and deletion
- woocommerce post_type conflict with existing post type
- ACF Post Content Not Being Searched
- Values show up in custom home page but not in custom post pages
- Custom Taxonomy not working front side Woocommerce
- WooCommerce breadcrumb display custom posts instead of product data
- Display related post content and custom field content
- How can I save a Custom Post Title and Slug with a Custom Field?
- WordPress page not showing up – replaced with last 10 posts?
- Custom permalink rewrite rules – how do I fix this?
- Custom Field as Custom Post type element class
- Extracting Post ID and passing through as an attribute in a shortcode
- 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?
- Fixed custom fields depending on posttype/category
- 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
- Group/list/sort custom post type posts by date in tabs from acf datepicker field
- How to make a custom search template for custom taxonomy?
- Making my custom column sortable
- Grouping and paging CPT events by month with custom field date
- Can’t pick up a field created with Advanced Custom Fields
- Custom Taxonomy is disabled on Edit page
- How to load custom post type plugin after acf options page (or get settings from there another way)?
- CPT or Custom Table for Repository of Serial Numbers
- Get Non-Paginated Index of Post in Paginated Query
- Custom post tag images not displaying with ACF
- Filter Content on all Post Types
- Get month and day from a Date Picker custom field
- Complex strcuture as CPT or taxonomy for use in woocommerce product variations [closed]
- Advanced Custom Fields – Add Field to Specific Page [closed]
- How to query posts by meta keys AND under specific category?
- $post breaking container loop
- Custom Search Template for Custom Post Types
- using ACF datepicker to filter posts on a page
- Get post id of permalink for a specific custom post type?
- how to load custom single.php?
- Setting a custom $query->query_vars[‘meta_key’] breaks the WordPress menu
- Function that get ACF fields value before saving
- Collection of fields in a single post
- Modifying and Displaying URL’s in a Post Template using parse_url
- If you’re calling a dynamic css inline style does that div have to be in the loop?
- How to query the content of a specific custom post type?
- If i have custom post type with 5 custom fields do i have to create a new loop to reference each one?
- Custom post type adding additional markup
- Advanced Custom Fields: query posts filtered by multiple field values
- Copying custom field value in to title
- Custom Post-type not returning the right child_of
- How to show animal lineage/pedigree in WordPress?