WP All Import / Wordpress / Woocommerce - skip item import if price is missing

366 views Asked by At

I'm using WP All Import Pro to import products into WooCommerce. In my import XML file, the first item for each product including variations is missing price and should therefore be skipped during the import.

I've placed the following code into my function editor in WP All Import, but it's not working. I'm not sure if I'm missing anything else, but any help is greatly appreciated.

Thanks

function skip_if_price_missing( $continue_import, $data, $import_id ) {
    
    $productLinePrice = $data['regular_price'];
    
    if ( $productLinePrice == '') {

        // If product doesn't exists then skip importing.
        return false;

    } else {

        // Else, import the product.
        return true;

    }
}

add_filter('wp_all_import_is_post_to_create', 'skip_if_price_missing', 10, 3);
0

There are 0 answers