Search Element always returns page results

Greetings!

I’m currently working on a layout for WooCommerce Archive for use as Shop page. I have installed the Search Element in a section at the top of the page to allow product searches. The search returns on what appears to be blog format with products, pages, and posts as results.

What I want to happen, is just search products, returning only products, and displaying them on the Archive Layout.

I currently have both woocommerce search widgit in the sidebar of the layout, along with the search element at the top of the page. When I use the sidebar search, it returns only products (with &post_type=product as the end of the URL). When using the Search element, I get the pages, posts and products (without the &post_type=product as part of the URL).

If a get the results back from the Search element, and manually add &post_type=product to the end of the results URL in the address bar of the browser, the page refreshes using the Layout for the Woocommerce archive.

Is there a way to have the search element perform the same as the woocommerce search widgit in the sidebar? Or maybe a way of adding the &post_type=product to the end of the url before it is returned? Or is there a way to put the woocommerce widigt on place of the search element and be able to style it?

Hello @mwr1701,

Thanks for writing in!

If you have used Loopers in your layout, please refer to this thread to accomplish what you have in mind:

Or you can manually insert a JS code as indicated on this thread:

Hope this helps.

Hi @ruenel,
I think I have loopers, but want to confirm… I set up the layout using the woocommerce archive template. If I am looking at my layout in the builder, the “Product” Element shows as a LOOPER CONSUMER.

So, refering to the customise search results using loopers above… would I be adding the Looper Provider as noted here to my product element which is the Consumer? Or am I missing the boat here…

I tried playing around with the Looper Provider, to no avail.

I also tried the JS code added to the layout custom JS… the JS does not seem to append anything to the search form when doing “view Source” in browser. Maybe the selector is incorrect??

Hi @mwr1701,

I have checked all three search boxes in your website Shop page and it shows only the matching Products in the result. The JavaScript code in the reference thread is adding a hidden HTML input at the Runtime and that is why it cannot be seen in the View Source, but you can see through the Browser Debbuger tools.

Thanks

Thanks @tristup, I am really confused as to why it did not seem to be working last night, but this morning it is… but at least it’s working! Thanks for all of your help!

Hi @mwr1701,

Glad that we are able to help you.

Thanks

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.