All Topics
Inline Editing Product Variations – Update Post
Hi,
We’re editing product variation prices using the inline edit option.
We need to update the post “modified date” to enable our sync back to Quickbooks to see that there was a change and fire the sync.
I have added this piece of code, but not seeing any results?
/**
* By default, the post modified date is not always updated when using inline or bulk edit with Admin Column Pro.
* For example, when updating meta data the <code>wp_update_post</code> is not called, which is the call that set then post's modified date.
* In this example we will trigger this call manually.
*
* @param AC\Column $column
* @param int $id
*/
function acp_editing_update_post_modified_date( AC\Column $column, $id ) {
$meta_type = $column->get_list_screen()->get_meta_type();
// Update the <code>modified_date</code> after making any changes using inline or bulk editing
if ( AC\MetaType::POST === $meta_type ) {
wp_update_post( [ 'ID' => $id ] );
}
// Update the <code>modified_date</code> after making changes to a specific custom field
if ( AC\MetaType::POST === $meta_type && $column instanceof AC\Column\Meta && 'my_custom_field' === $column->get_meta_key() ) {
wp_update_post( [ 'ID' => $id ] );
}
}
add_action( 'acp/editing/saved', 'acp_editing_update_post_modified_date', 10, 2 );
Any suggestions?
Thanks!
You must be logged in to reply to this topic.