Tips and Tricks HQ Support Portal › Forums › WP eStore Forum › WP eStore Troubleshooting › eStore – search shortcode not working
Tagged: product search, shortcode
- This topic has 7 replies, 3 voices, and was last updated 11 years ago by markpr.
-
AuthorPosts
-
October 26, 2013 at 6:31 am #9907markprMember
I developed my wordpress site in a subdirectory of the root. Everything worked fine.
Now I “pointed” the wordpress install to the root URL. The shopping cart works fine, but I have a shortcode for the cart search in my sidebar widget. I used this one:
[wp_eStore_product_search]
Now, when I try to search — a new page opens at this URL:
[http://p-rposters.com/subdirectory/#eStore_search_anchor]
Is there a way to get the search to work even though the plugin is in a subdirectory with all of the wordpress files?
Maybe something like adding a URL to the shortcode like this:
[http://p-rposters.com/subdirectory/?wp_eStore_product_search]
If you want to try it for yourself, you can go to my website:
[http://p-rposters.com/]
and the search is in the right sidebar about half way down.
Someones help will be greatly appreciated.
Thanks
October 26, 2013 at 11:23 pm #58479adminKeymasterDo you have two different WordPress installs in this domain (One in the root and one in the sub-directory)?
If you do then read the following post which should help:
https://support.tipsandtricks-hq.com/forums/topic/wp-multisite-install-and-plugin-behavior
October 27, 2013 at 12:35 am #58480markprMemberNo, I’m not using two wordpress installs.
I have the wordpress folders and files in a subdirectory below the root.
So, when I try to search it loads the shortcode from the subdirectory and won’t give me any search results. The page it loads is this URL:
[http://p-rposters.com/subdirectory/#eStore_search_anchor]
I’m trying to find a way to specify in the shortcode (or somewhere in the admin) to get rid of the /subdirectory reference. And what is eStore_search_anchor?
I’m lost. Do I need to install the search plugin in the root?
October 27, 2013 at 7:14 pm #58481markprMemberI was looking at the code in eStore-extra-shortcodes.php
Would using a specific URL in this search code do the trick?
Like using: [http://p-rposters.com/#eStore_search_anchor] for the form requests?
Again, I’m trying to get the search shortcode to work — I have the wordpress files and plugins in a subdirectory, but have the website URL set to the root.
function wp_eStore_product_search_handler($args)
{
extract(shortcode_atts(array(
‘search_category’ => ”,
‘category_id’ => ”,
), $args));
$output = “”;
if(!defined(‘WP_ESTORE_PRODUCT_SEARCH’)){define(‘WP_ESTORE_PRODUCT_SEARCH’,’Product Search’);}
$output .= ‘<div class=”eStore_product_search_box”>’;
$output .= ‘<div class=”eStore_product_search_label”>’. WP_ESTORE_PRODUCT_SEARCH. ‘</div>’;
$output .= ‘<form method=”post” action=”#eStore_search_anchor”>’;
$output .= ‘<input name=”eStore_product_search_term” class=”eStore_product_search_input_field” type=”text” size=”30″ value=””/>’;
$output .= ‘<div class=”eStore_search_submit”>’;
$output .= ‘<input type=”submit” name=”eStore_product_search” value=”Search” />’;
$output .= ‘</div>’;
$output .= ‘</form>’;
$output .= ‘</div>’;
if(isset($_POST))
{
$search_term = strip_tags($_POST);
$output .= print_eStore_product_search_result($search_term,$search_category,$category_id);
}
return $output;
}
Sorry to be such a bother. It just seems to me there is a workaround for this issue.
Thanks.
October 27, 2013 at 10:30 pm #58482mbrsolutionSpectatorHello markpr, you say you developed your WordPress site in a subdirectory of the root. Everything worked fine. Then you “pointed” the wordpress install to the root URL and the shopping cart worked well.
My question is this, Why aren’t you moving the WordPress website to the root?
Kind regards
October 27, 2013 at 10:45 pm #58483adminKeymaster@markpr, When you do a search, the data is posted back to the same page and the plugin does the search then shows the result. For some reason, on your site the HTTP REQUEST variable is still pointing to the sub-directory. This indicates an issue somewhere in your sub-directory to root redirection setup that you have.
Anyway, Using the following value as the form action should do the trick:
[http://p-rposters.com/#eStore_search_anchor]
October 27, 2013 at 11:33 pm #58484markprMemberThat does the trick. Thanks so much.
November 10, 2013 at 4:51 pm #58485markprMemberFor those of you who need to do this, Go to your wordpress admin panel -> then to plugins -> then to editor -> then choose Extra shortcodes for WP eStore in the drop down box in the top right of the page -> then choose the eStore-extra-shortcodes/eStore-extra-shortcodes.php file.
In this file you will find the following code:
function wp_eStore_product_search_handler($args)
{
extract(shortcode_atts(array(
‘search_category’ => ”,
‘category_id’ => ”,
), $args));
$output = “”;
if(!defined(‘WP_ESTORE_PRODUCT_SEARCH’)){define(‘WP_ESTORE_PRODUCT_SEARCH’,’Product Search’);}
$output .= ‘<div class=”eStore_product_search_box”>’;
$output .= ‘<div class=”eStore_product_search_label”>’. WP_ESTORE_PRODUCT_SEARCH. ‘</div>’;
//$output .= ‘<form method=”post” action=”‘.$_SERVER[“REQUEST_URI”].’http://YOUR-DOMAIN-NAME.com/#eStore_search_anchor”>’;
$output .= ‘<form method=”post” action=”http://YOUR-DOMAIN-NAME.com/#eStore_search_anchor”>’;
$output .= ‘<input name=”eStore_product_search_term” class=”eStore_product_search_input_field” type=”text” size=”30″ value=””/>’;
$output .= ‘<div class=”eStore_search_submit”>’;
$output .= ‘<input type=”submit” name=”eStore_product_search” value=”Search” />’;
$output .= ‘</div>’;
$output .= ‘</form>’;
$output .= ‘</div>’;
I simply put my domain name (http://YOUR-DOMAIN-NAME.com/) before the #eStore_search_anchor and saved the file.
This worked for me.
I needed to do this because I developed my wordpress website in a subdirectory below the root directory of my domain. Before I changed this code, anytime I tried to get the search to work, it would try to load the search results using the URL with the subdirectory name in it. That did not work.
Thanks for the help Admin.
-
AuthorPosts
- You must be logged in to reply to this topic.