Woocommerce search in topbar

Hi,

I am trying to ad the woocommerce search shortcode in the topbar, but it is just displaying the actual code. how do i get it to display properly.

Hi There,

Thanks for writing in! By default, shortcodes do not work in the topbar. Only text and html is allowed. It can only be done by some modifications.

Make sure that you have a child theme setup and activated. Then try adding the following code into your child theme’s functions.php file.

function topbar_content_filter( $output ){
  return do_shortcode( $output );
}
add_filter( 'x_option_x_topbar_content', 'topbar_content_filter' );

Hope that helps.

Hi Thanks for that. but it did not work.

Hi there,

I have tried to login using the details you have provided but I am getting the error:

Invalid email address.

Kindly double check.

For the meantime, please also make sure you have added the code in the functions.php file of the child theme and that you are using the correct shortcode.

Cheers!

Sorry there is no .au after

Hi there,

I checked your site and the code is added correctly in the functions.php file of the child theme. Though I was not able to see any shortcode added in the topbar content so I am not certain which one you are trying to add.

I have tried adding the line shortcode [x_line] in the topbar and it seems to work fine. Whatever shortcode you will add to the topbar should work. Kindly double check if you are using the correct shortcode.

I was trying to ad the one I showed you in this thread in the screenshot. [woocommerce_product_search]

I took it out because it showed the text in the top bar instead of a search bar.

Hi there,

The woocommerce product search shortcode will only work if you have the Woocommerce Product Search plugin and as I have checked, you do not have it installed and activated on your site.

Oh, thanks. I thought it was part of woocommerce.

Do you know how to get a woocommerce search in the topbar or header.
When I turn it on in X people find my hidden products. So I need woocomerce search

Hi there,

Please add your shortcode to your topbar content, then enable the shortcode by adding this to your child theme’s functions.php

add_filter('x_option_x_topbar_content', 'top_bar_content_shortcode');
function top_bar_content_shortcode ( $content ) {
return do_shortcode ( $content );
}

Hope this helps.

HI that didn’t work because I do not have the woocoommerce search plugin. So I was asking if there was a seperate way to get woocommerce search bar somehow on the header or topbar.

Hi,

You can add this in your Topbar Content

<form method="get" id="searchform" class="form-search" action="https://eurekawellness.com.au/" _lpchecked="1">
  <label for="s" class="visually-hidden">Search</label>
  <input type="text" id="s" class="search-query" name="s" placeholder="Search" style="outline: none;">
</form>

Hope this helps

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