• Resolved eavinu

    (@eavinu)


    Hi Chouby,

    I found some very old info about problems with the is_search function but I believe that the old problem was resolved in the later versions.
    However I am using the current version and also woocommerce and I have a problem with the is_search function…

    In the main language the is_search is working perfectly but with the other language it is not working. (English – /en/)

    Another problem in the search results page, in the main language I have in the body class “archive” and also “tax-product_cat” when the search string includes specific product category and also specific product tag.
    In English I don’t have those in the search results body class and I must have them as they are used both in the CSS and in some php if’s.

    I hope you may have an idea about the why the problems are caused and find a cool fix for me or maybe even everyone else that might have such issue.

    By the way, my search filter looks like this (its a dropdown populated with product tags shown in each category):
    Main language:
    http://THE-DOMAIN-NAME/?s=&product_cat=THE-CATEGORY-THAT-WE-FILTERED-IN&product_tag=THE-SELECTED-TAG

    English:
    http://THE-DOMAIN-NAME/en/?s=&product_cat=THE-CATEGORY-THAT-WE-FILTERED-IN&product_tag=THE-SELECTED-TAG

    As you can see it looks as if they are exactly the same and should show properly…

    https://ww.wp.xz.cn/plugins/polylang/

Viewing 15 replies - 1 through 15 (of 15 total)
  • Plugin Author Chouby

    (@chouby)

    Hi!

    Not sure but from your explation, I understand that THE-CATEGORY-THAT-WE-FILTERED-IN and THE-SELECTED-TAG are a product cat and a product tag in the default language. So it is expected to get empty results when you query them in English.

    You must tranlate these product cat and product tag. If you have some PHP knowledge, you can use the Polylang API function pll_get_term to do this.

    Thread Starter eavinu

    (@eavinu)

    Thank you for the so fast asnwer!

    As a matter of fact, the product tag and category tags are not taken from the default language and the results are being shown.

    The problem is that I modified woocommerce.php with some if is_search() and some if !is_search() functions.

    I will add another private comment with links to show you the difference between the languages (I am just the developer not the owner of the site so I don’t want to post links to it here)

    Thread Starter eavinu

    (@eavinu)

    OK I forgot that there is no private reply here so I am sending you links in a message to show the problem.

    Thread Starter eavinu

    (@eavinu)

    I will add links here as I can’t find where to message you as well šŸ™‚
    Later I will erase the links once you see them:

    Main language (Hebrew):
    http://winners-auctions.com/?s=&product_cat=%D7%9E%D7%9B%D7%99%D7%A8%D7%94-%D7%9E%D7%A1%D7%A4%D7%A8-085&product_tag=%D7%9B%D7%AA%D7%95%D7%91%D7%95%D7%AA

    English:
    http://winners-auctions.com/en/?s=&product_cat=auction-no-085&product_tag=ketubot

    Here I am showing you the same category and same tag filtered in the corresponding language so you can see the exact same search results but the page layout is wrong in English.
    I found that the English page is showing the content that is defined under the !is_search and the Hebrew page shows the correct content from the is_search definition that I made.
    Another thing that affects the CSS and also a definition used in woocommerce.php is that in Hebrew the body class contains “archive tax-product_cat” and in English those are missing.

    Any idea?

    Plugin Author Chouby

    (@chouby)

    Looking at your html source (the body tag), your problem seems not to be the search (the class is present) but rather the classes related to taxonomies which disappear. No idea why as I can’t reproduce on a simple install (with Polylang as only plugin).

    Thread Starter eavinu

    (@eavinu)

    maybe it is a problem with interaction with Woocommerce?

    Any idea at all?
    In Hebrew which is the main language there is no problem at all…

    Plugin Author Chouby

    (@chouby)

    Not specifically with Woocommerce. But further tests showed me that this bug appears for custom taxonomies (not categories and tag which I initially tested). I will go on working on this and come back to you.

    Thread Starter eavinu

    (@eavinu)

    I understand, indeed we are using the custom taxonomies such as the product_cat and product_tag and not the regular wordpress category and tag taxonomies.

    Looking forward to your solution!

    Is it okay to remove the links that I added above?

    Plugin Author Chouby

    (@chouby)

    Is it okay to remove the links that I added above?

    Yes if you are able to.
    Could you please test the new development version (1.6.4.3)?
    https://downloads.wp.xz.cn/plugin/polylang.zip

    Thread Starter eavinu

    (@eavinu)

    I wasn’t aware but the Edit option for posts is available for only one hour after it was posted so can’t erase the links… never mind.

    Now after this new version we are almost there! A great improvement.

    Now infact the is_search is working and we can see that the “archive” definition is in the body class.
    The more important definition is still missing from the body class, it is for the following usage for the layout:

    if (in_array('tax-product_cat',$classes)) {

    I use this to differentiate between regular search results layout and the layout of this custom filter which is based on the search function.

    You think that this can also be resolved? I think that it is still related to the custom taxonomies but you should know better…

    Thread Starter eavinu

    (@eavinu)

    By the way, you can see in the English page now 2 search fields, one should be there when it is not (in_array(‘tax-product_cat’,$classes)), for the regular search results but it is showing because the tax-product_cat is missing from the body class.

    Thread Starter eavinu

    (@eavinu)

    While it is not the best solution for me, for now I will change the condition to check if we have “archive” in the body class as in the regular search it doesn’t have it so it will still differentiate the results layout.

    Please update me if you managed to fix the tax-product_cat issue.

    I wish to thank you now but I will save it for when I mark this topic as solved šŸ™‚

    Thread Starter eavinu

    (@eavinu)

    OK sorry for the flood, one last update:

    If I use the search in the header, Hebrew and English results are fine as both are without “archive” in body class.
    When using the search inside a category there is a problem as those results do have archive in them but they don’t have tax-product_cat and hence it doesn’t have the correct layout that it should have.

    Hope that you manage to sort it and fix so that all the taxonomies from are taken to the secondary language as well as this is the only way to fix my issue here…
    Thanks!

    Plugin Author Chouby

    (@chouby)

    Could you try the new development version (1.6.4.4)?
    https://downloads.wp.xz.cn/plugin/polylang.zip

    Thread Starter eavinu

    (@eavinu)

    Just like magic!
    Perfect!

    You can look now in the 2 links and now we can actually match the body classes in both languages and also the is_serach is working as it should for woocommerce šŸ™‚

    I am happy to have been able to raise an issue which promoted your code closer to perfection…

    Thank you thank you thank you and again thank you!

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

The topic ‘is_search problem’ is closed to new replies.