• Resolved freakency

    (@freakency)


    We are using a product called ATUM inventory. This allows us to create Raw Materials products. These are coded to not appear in searches as they are not for users to buy.

    Indeed on the search results page they do not show. However on the AJAX search they do appear even though there are hooks to remove them from the shop list page, product page and the default WP search.
    So I am guessing this AJAX search works a different way.

    My question is do you have code that will also remove these results in the AJAX search?

    Or if i put them in a category or tag them, is there a way to filter these out in functions so they also don’t show in the AJAX search results drop down?

    many thanks

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

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author ILLID

    (@mihail-barinov)

    Hello,

    Can you please give me some screenshot of ATUM inventory plugin dashboard where I can see how you made these product hidden for the search results?

    Regards

    Thread Starter freakency

    (@freakency)

    Hi ILLID,

    ATUM are using hooks to filter rather than using the product level hidden product. (we have also tried making the raw material product hidden but this also surprisingly still shows in the AJAX search)

    They have said:

    https://www.stockmanagementlabs.com/addons/atum-product-levels/
    “We’ve added some hooks to Product Levels to prevent they from showing on standard WooCommerce queries (like the shop list page or the product page or the default WP search) but if this plugin you are using is not following the WooCommerce standards to search for products, it’s going to just show up all the products you have (no matter is a BOM or not).”

    Happy to get the code they used if that makes it easier, or a category filter solution.

    Here is a screenshot of the setting to hide these products: https://ibb.co/X3sm4Y9

    Plugin Author ILLID

    (@mihail-barinov)

    Looks like I found the solution for you. Please use following code snippet

    add_filter( 'aws_indexed_data', 'my_aws_indexed_data', 10, 2 );
    function my_aws_indexed_data( $data, $id ) {
        if ( class_exists( 'AtumProductLevelsAddon' ) ) {
            $is_purchasable = AtumLevels\Inc\Helpers::is_purchase_allowed( $id );
            if ( ! $is_purchasable ) {
                $data = array();
            }
        }
        return $data;
    }

    You need to add it somewhere outside the plugins folder. For example, inside functions.php file of your theme or use some plugin for adding code snippets.
    Also, after adding this code, you need to re-index the plugin table.

    Thread Starter freakency

    (@freakency)

    Thank you ILLID much appreciated

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘filter AJAX search results’ is closed to new replies.