Navigation überspringen

Dies ist das technische Support-Forum für WPML – das mehrsprachige WordPress-Plugin.

Mitlesen können alle, doch nur WPML-Kunden können hier Fragen veröffentlichen. Das WPML-Team antwortet im Forum an 6 Tagen pro Woche, 22 Stunden am Tag.

Dieses Thema enthält 1 Antwort, hat 2 Stimmen.

Zuletzt aktualisiert von Marcel Vor 1 Jahr, 9 Monaten.

Verfasser Beiträge
Mai 22, 2023 unter 12:45 pm #13690083

Frank

woocommerce-products are only generate in one language - to custom output them, we switch on other-language page for output the product-data to the default language.

We used a function to get the default language:
function getDefaultLang ($bDebug = false ) {
return ( apply_filters( 'wpml_default_language', NULL ) );
}

$currentLang = getLang();

if ( $currentLang != $defaultLang ) {
do_action( 'wpml_switch_language', $defaultLang() ); // line 1537

do_action( 'wpml_switch_language', 'DE' ); // works fine, but we do not like hard-coded languages
}

And we use the following construct to check if default != current lang and the we switch before output product data. later we switch back.

it works fine but actualy we get an error:

Fatal error: Uncaught Error: Call to undefined function de()
in /wp-content/... on line 1537 (the switching-line)

Seems the action returns a function and not a string with the lang-code?!

Docu:
- https://wpml.org/wpml-hook/wpml_default_language/
- https://wpml.org/wpml-hook/wpml_switch_language/

Mai 22, 2023 unter 4:53 pm #13693079

Marcel
Supporter

Sprachen: Englisch (English ) Deutsch (Deutsch )

Zeitzone: Europe/Madrid (GMT+01:00)

Hallo,

bevor Ihr Ticket einem meiner Kollegen zugewiesen wird, erlauben Sie mir bitte, Sie durch einige erste Schritte zur Fehlersuche zu führen.

#1 Bitte fügen Sie die gesamte Stack Trace des Fatal Errors ein.

woocommerce-products are only generate in one language - to custom output them

#2 Es wäre zudem hilfreich, wenn Sie dies genauer erklären, was genau Sie wie ausgeben wollen. Ggf. können Sie es einfacher über die WooCommerce Multilingual API erreichen: https://wpml.org/documentation/related-projects/woocommerce-multilingual/wcml-hooks-reference/.

Bitte um Info

Freundliche Grüße
Marcel

Das Thema '[Geschlossen] wpml_default_language, wpml_switch_language with action won't work any more' ist für neue Antworten geschlossen.