Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › WPML and Products are not displaying
- This topic has 23 replies, 2 voices, and was last updated 2 years, 7 months ago by
vantinh.
-
AuthorPosts
-
October 30, 2023 at 12:29 pm #45865
vantinh
ParticipantYou cannot access this content.
October 31, 2023 at 10:56 am #45872Ernest Marcinko
KeymasterYou cannot access this content.
October 31, 2023 at 11:53 am #45873vantinh
ParticipantYou cannot access this content.
November 2, 2023 at 10:24 am #45883Ernest Marcinko
KeymasterThanks!
I think I have a solution for you. I have placed the following custom code to the functions.php file in the avada-child theme directory:
add_filter( 'asp_results', 'asp_change_lang_on_wpml', 10, 4 ); function asp_change_lang_on_wpml( $results, $search_id, $is_ajax, $args ) { global $sitepress; // Let us get the default site language if possible if ( is_object($sitepress) && method_exists($sitepress, 'get_default_language') ) { $site_lang_selected = $sitepress->get_default_language() == $args['_wpml_lang']; } $lang = $args['_wpml_lang']; var_dump($site_lang_selected); if ( !$site_lang_selected ) { foreach ($results as $k=>&$r) { if ( isset($r->post_type) && $r->post_type == $post_type ) { //$r->link = str_replace("/product/", "/product/".$lang."/", $r->link); $r->link = apply_filters('wpml_permalink', $r->link, $args['_wpml_lang'], true); } } } return $results; }So right now when I test on the english, I only get english or the ones that should show on both, with english URL. For the german, I turned off the compatibility (search ID=2) and now shows everything, and the URLS are corrected via the code.
November 2, 2023 at 12:56 pm #45884vantinh
ParticipantHi,
This is so good. I can keep the users still on German or English. It was mixing between EN and DE .
Now, I am having more ES ( Spanish).
Can I turn on the compatibility WPML ON ? and should I take all results from other languages ? or must I set turn off ?
I did not understand what is your logic with the configuration WPML in your plugin. Because, The avada search does not have this config , but it returns all products if that are available .
Here is the translated page for ES : https://ticket.botiss-dental.de/es/beispiel-seite/
Thanks
November 2, 2023 at 1:32 pm #45885Ernest Marcinko
KeymasterSure – if you turn it on, then it will automatically filter items which do not belong to the current language. That will not affect the code itself, it will still convert the URLs if not the default site language is detected.
November 2, 2023 at 3:07 pm #45887vantinh
ParticipantOkI understand.
Someone wants to turn on WPML to see only item which is belonging to the selected language.
If you do not have this configuration as avada Element, the users can not control which items would be shown or hidden . So, the config WPML ON and OFF would be suitable for everyone.
At the begin of using your plugin, I think you created the config wpml on wrong way. But, No you are right.
Conclusion: I will create more shortcode on DE and ES and then I will turn off WPML setting. Last, I have to exclude some categories of other languages. Our problem is that we have a category with products only on English, but we want to display that on all languages.
how do you think about this solution ?
November 3, 2023 at 2:26 pm #45893Ernest Marcinko
KeymasterTry to open the admin dashboard in “All languages”: https://i.imgur.com/hZT0s5K.png
With that I think WPML should allow excluding categories from other languages as well.November 3, 2023 at 2:29 pm #45894vantinh
ParticipantOki let me check it on Monday next week. Thank you
-
AuthorPosts
- You must be logged in to reply to this topic.