• Resolved webtica

    (@webtica)


    Hi woo forum,

    I was wondering if someone could help me with this.
    I am using wp all import to import some products. In total there are 5025 products where 500 are published and the rest is Draft.

    I am using wp all import to sync the stock but i want to update only the ones that are published so not the draft ones.

    I contacted the wp all import team and they gave me half of the code but i can’t figure out the rest.
    Here is what i have and tried:
    This is my code :

    <?php
    function do_not_update_if_draft($post_id, $data, $import_id)
    {
        // Check for your import
        if ($import_id == 5) {
            // Check if product is draft
            if ( get_post_status ( $ID ) == 'draft' )
                return false;  
            }
            else {
                return true;
        }
    }
    add_filter('wp_all_import_is_post_to_update', 'do_not_update_if_draft', 10, 3);
    ?>

    this doesn’t seem to work. they mailed me the following:

    “You should be able to get the post status by using the get_post_status function on the $post_id variable, and then storing the result in another variable. You’d then write an if/else statement to check & see if the value in your variable is equal to draft, and return the appropriate value (false if the value is equal to draft, true if it does not equal draft).”

    Any ideas how i can make this small problem fixed?

    Thanks
    Dieter

    They also gave this page as an example: https://github.com/soflyy/wp-all-import-action-reference/blob/master/all-import/wp_all_import_is_post_to_update.php

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Don’t import when draft.’ is closed to new replies.