• Resolved vladimirvuch

    (@vladimirvuch)


    Good day.

    I need a little help.
    I try not to import products in woocommerce relative to the price.
    Currently not received and all products are ignored.


    // Snippet from AllImport for not create productions
    add_filter( ‘wp_all_import_is_post_to_create’, ‘my_check_to_create’, 10, 3 );

    function my_check_to_create( $continue_import, $data, $import_id ) {

    $productLinePrice = $data['regular_price'];
    
    if ( empty($productLinePrice) || $productLinePrice == '' || $productLinePrice < 3.00) {
    
        // If product doesn't exists then skip importing.
        return false;
    
    } else {
    
        // Else, import the product.
        return true;
    
    }

    }

    • This topic was modified 1 year, 5 months ago by vladimirvuch.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author WP All Import

    (@wpallimport)

    Hey @vladimirvuch,

    Is the price element in your import {regular_price[1]}, or is it something else? If it’s something else, you have to update this line:

    $productLinePrice = $data['regular_price'];

    For example, if it’s {price[1]}, you’d update it to:

    $productLinePrice = $data['price'];

    That said, we aren’t able to help modify/troubleshoot custom code, but we can keep this thread open in case someone is willing to help out.

    Thread Starter vladimirvuch

    (@vladimirvuch)

    In my different imports, the elements are called differently.
    In someone is price, regular_price and cena.
    Inputs are said differently in different places.
    Isn’t that the name that comes from woocommerce?

    Plugin Author WP All Import

    (@wpallimport)

    Hey @vladimirvuch,

    Isn’t that the name that comes from woocommerce?

    Yes, “_regular_price” is the name of the custom field that they keep the price in, but the $data variable in this code contains the import record’s data. For example, in this record – https://d.pr/i/AKtNfA – it would contain the elements “price”, “saleprice”, “stock”, etc.

    In my different imports, the elements are called differently.
    In someone is price, regular_price and cena.

    In that case, you could adjust the code to only run for a certain import ID (using an IF conditional on the $import_id variable) so that you know which element to use. Or, you could check which one exists in the $data variable using isset().

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Need help with wp_all_import_is_post_to_create’ is closed to new replies.