Include product body field in Shopify drawer search results




Introduction

Many themes don’t include the body field as part of the search condition in the drawer (the search that appears when clicking the search icon in the top-right corner).

In some cases, you may want to include the body field in search results.



Solution

Before making any changes, it’s highly recommended to create a backup copy of your theme by clicking the Duplicate button.

Go to Online Store → Themes, and on your current theme, click Edit code:

Edit code button

Next, search for the term "resources[options][fields]" in your theme’s files. This is often found inside a file like search.js.

For example, you might see a line like this:

url.searchParams.set('resources[options][fields]', 'title,product_type,variants.title,variants.barcode');
Enter fullscreen mode

Exit fullscreen mode

Modify it to include the body field:

url.searchParams.set('resources[options][fields]', 'title,product_type,variants.title,body,variants.barcode');
Enter fullscreen mode

Exit fullscreen mode



Testing

Finally, test the search feature to ensure it works as expected.

If you encounter any issues (such as the drawer not opening or no results appearing), check the browser’s developer console for JavaScript errors or inspect the network requests and responses.



Source link

Leave a Reply

Your email address will not be published. Required fields are marked *