This website uses cookies to personalize your experience. By using this website you agree to our cookie policy.

WPML and Products are not displaying

Home Forums Product Support Forums Ajax Search Pro for WordPress Support WPML and Products are not displaying

Viewing 9 posts - 16 through 24 (of 24 total)
  • Author
    Posts
  • #45865
    vantinhvantinh
    Participant

    You cannot access this content.

    #45872
    Ernest MarcinkoErnest Marcinko
    Keymaster

    You cannot access this content.

    #45873
    vantinhvantinh
    Participant

    You cannot access this content.

    #45883
    Ernest MarcinkoErnest Marcinko
    Keymaster

    Thanks!

    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.

    #45884
    vantinhvantinh
    Participant

    Hi,

    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

    #45885
    Ernest MarcinkoErnest Marcinko
    Keymaster

    Sure – 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.

    #45887
    vantinhvantinh
    Participant

    OkI 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 ?

    #45893
    Ernest MarcinkoErnest Marcinko
    Keymaster

    Try 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.

    #45894
    vantinhvantinh
    Participant

    Oki let me check it on Monday next week. Thank you

Viewing 9 posts - 16 through 24 (of 24 total)
  • You must be logged in to reply to this topic.