Skip Navigation

[Resolved] Display all products regardless of language

This support ticket is created 5 years, 6 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 11 replies, has 2 voices.

Last updated by Christian Cox 5 years, 5 months ago.

Assisted by: Christian Cox.

Author
Posts
#1135010

I am trying to: Display all products regardless of language on the product archive/ shop page

I tried:

add_action( 'pre_get_posts', 'wpml_custom_query' );

function wpml_custom_query( $query ) {
     if( $query->query_vars['post_type'] == 'product' ) {
          $query->query_vars['suppress_filters'] = true;
     }
}

At the moment no products at all are displayed. I don't know why.

Post Types Translation product in the WPML settings menu is set to "not translatable".

Please help.

#1135016

I also tried:

add_filter( 'wpv_filter_query', 'disable_wpml_func', 10, 3 );

function disable_wpml_func( $query_args, $view_settings, $view_id ) {
    if ( $view_id == 1050 ) {
         $query_args['suppress_filters'] = true;
    }
    return $query_args;
}

for views. But it didn't work either. No results are shown at all.

#1135094

I have the WPML plugin installed

#1135115

I accidentally closed this ticket

#1135713

Hi, since WPML 3.9 the preferred method is to choose "Translatable - use translation if available or fallback to default language," and create Products in the site's default language. Then all Products will be shown in all languages. If some Products are not created in the default language, you must translate the posts into the default language or copy them into the default language with custom code. https://wpml.org/2018/01/wpml-3-9-released/

Is there a specific reason why you would prefer to use the "Not translatable" option for Products? If I understand, I might be able to offer a better solution.

#1136012

Thanks, Christian.

Yeah, so products can be added through the frontend. Products should always be added in English. However sometimes when a German-speaking user adds a product through the /de/ subdirectory a German product will be added. I'd like to avoid that, so I am curious how I can control that with CRED/toolset forms.

Regards,
Nick

#1136134

I'd like to avoid that, so I am curious how I can control that with CRED/toolset forms.
Nothing in CRED / Forms will prevent Users from adding content in a secondary language. That restriction should be enforced with WPML, so German visitors are never shown the Create Product Form on the German site. Redirect German visitors to create content on the default language site instead. The page containing the Form could include instructions and field labels in both English and German, but should not be translated into the secondary language site.

#1136305

Hm... at the moment there's the option to make none translated products appear as translated on the frontend.
This feature works quite well for me if I add a product through the wordpress admin. I see the english product but the language is in german.

Using CRED I'd like to add an english product but make it appear as translated. Only the texts of the form page should be translated.

#1136319
Screen Shot 2018-10-30 at 12.05.16 AM.png

So the product should only appear as translated. And it shouldn't matter where the product was submitted whether it was on the /de or /en part of the site, however, all products he submits should only appear as translated even though they have been saved in English in the WP admin.

I am looking for something like


add_action('cred_save_data', 'my_save_data_action',10,2);
function my_save_data_action($post_id, $form_data){
  // if a specific form
  if ($form_data['id']==9999){
        
       do_action( 'wpml_submit_post_in_default_english_language_but_make_it_appear_translated', $post_id );            
  }
}

#1136814

So the product should only appear as translated. And it shouldn't matter where the product was submitted whether it was on the /de or /en part of the site
Unfortunately with WPML it does matter where the product was submitted. If you want a product to appear in both /de and /en without having been translated, it must be submitted in a Form on the default language site. The text on the page containing the Form will not be in a secondary language unless you add that secondary language content on the primary language site. That's why I mentioned that you could include text in both languages on the default language page containing the default language Form - the same page and the same Form is used for content submission in all languages.

I will ask my 2nd tier team if there's any code-based solution here, but last I checked there is none. I'll let you know what I find out.

#1137417

Thanks, Christian.

#1137554

Okay I got feedback today from the WPML developers but unfortunately there is no better solution. The recommended workflow for having all Products appear in all languages without translation is to create Products with Forms in the default language site, and to select the "Translatable - use translation if available" option in WPML for the Products post type. There's no code-based solution at this time.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.