Home > OS >  Skip updating the content of the product according to the post meta field in WP all import plugin?
Skip updating the content of the product according to the post meta field in WP all import plugin?

Time:09-09

I am using the WP all import plugin to import and update product from SMPT. I have used it's WooCommerce extension. I have also created the meta field _skip_on_update_key which trigger '1' when you save that product from backend.

My issue is if _skip_on_update_key is 1 that that product should not be updated.

Thank you in advance.

CodePudding user response:

We can use 'wp_all_import_is_post_to_update' filter hook to check which post to update or not. Following code should work for you:

function skip_to_update( $continue, $post_id, $xml_node, $import_id ) {
    if (get_post_meta($post_id, '_skip_on_update_key', true) == 1) {
        return false;
    }
    else {
        return true;
    }
}

add_filter( 'wp_all_import_is_post_to_update', 'skip_to_update', 10, 4 );
  • Related