• Resolved ilyapokrov

    (@ilyapokrov)


    Thanks again for the wonderful plugin!
    Please tell me, when importing, if the product is not in the file, I change its visibility in the catalog using the following code:

    <?php
    function my_is_post_to_delete( $is_post_to_delete, $post_id, $import ) {
        // Unless you want this code to execute for every import, check the import id    
        // if ( $import->id == 5 ) { ... }
        if ( $product = wc_get_product( $post_id ) ) {
            $product->set_catalog_visibility( 'hidden' );
            $product->save();
        }
        return false;
    }
    add_filter( 'wp_all_import_is_post_to_delete', 'my_is_post_to_delete', 10, 3 );
    ?>

    How can I modify this code to change not only the visibility in the directory, but also:
    1) Specify the text “Out of stock” instead of the price
    2) Remove the Buy button
    3) Add the button “View the entire section of this category”

    I understand that I am impudent with such a request. But nevertheless, suddenly you have already encountered such a problem and you have a ready-made solution.

    Thank you so much!

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author WP All Import

    (@wpallimport)

    Hi @ilyapokrov,

    How can I modify this code to change not only the visibility in the directory, but also: 1) Specify the text “Out of stock” instead of the price 2) Remove the Buy button 3) Add the button “View the entire section of this category”

    That probably wouldn’t be possible with only a code snippet in WP All Import. You’d likely have to modify your theme template files that actually display the product data on the front end.

    Unfortunately, I do not have any example snippets for this specific use case. Sorry.

    Thread Starter ilyapokrov

    (@ilyapokrov)

    @wpallimport,
    On the second and third questions I agree. But the first one can be solved with code.
    After all, this feature is already preinstalled in the plugin.

    https://ganzola.ru/wp-content/uploads/2020/11/Screenshot_13.jpg

    Plugin Author WP All Import

    (@wpallimport)

    Hi @ilyapokrov,

    But the first one can be solved with code. After all, this feature is already preinstalled in the plugin.

    Yes, if you just need to import a value into a custom field, that will work fine.

    Plugin Author WP All Import

    (@wpallimport)

    Hi @ilyapokrov,

    I’m going to mark this as resolved since it’s been a while. If you still have questions, you can reply in this thread.

    Anyone else with questions, please open a new topic.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Changing the parameters of deleted items’ is closed to new replies.