Tell us what you are trying to do?
On checkout of a certain product type (tied to Toolset Commerce) I want to change the value of the Payment Status toolset custom field.
Is there any documentation that you are following?
I have this function in place and I wonder if it immediately obvious why my field value is not being changed?
function payment_complete( $order_id, $old_status, $new_status ){
if( $new_status == "completed" ) {
$user_id = get_current_user_id();
$args=array(
'post_type' => 'song-contest-entry',
'post_status' => 'publish',
'posts_per_page' => 1,
'author' => $user_id
);
$current_user_posts = new WP_Query ( $args );
//LOOP START
if ( $current_user_posts->have_posts() ) {
while ( $current_user_posts->have_posts() ) { $current_user_posts->the_post();
$payment_status = get_post_meta(get_the_ID(), 'wpcf-paymentstatus', true);
if ($payment_status == 'Unpaid') {
update_post_meta( $post_id, 'wpcf-paymentstatus', 'Paid' );
}
}
}
//LOOP END
}
}
add_action( 'woocommerce_order_status_changed', 'payment_complete', 99, 3 );
Is there a similar example that we can see?
Not that I am aware of.
What is the link to your site?