Questo thread è stato risolto. Ecco una descrizione del problema e della soluzione.
Problem: You need to set different labels and URLs for each language in the 'Return to the shop' snippet in a WooCommerce site using WPML. Solution: We recommend using one of the WPML hooks to dynamically change the URL based on the current language. You can use the
wpml_current_language
hook to detect the current language and then set the URL accordingly. Here is an example of how you can implement this:
If this solution does not apply to your case, or if it seems outdated, we highly recommend checking related known issues at https://wpml.org/known-issues/, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If you still need assistance, please open a new support ticket.
Questo è il forum di assistenza tecnica di WPML, il plug-in multilingue di WordPress.
La sua lettura è permessa a tutti, ma la pubblicazione è riservata esclusivamente ai clienti di WPML. Il team di WPML risponde sul forum 6 giorni su 7, 22 ore su 24.
Contesto del problema:
I am working on a site in development and need to have a different label and URL for each language (I use 3 languages) for the 'Return to the shop' snippet. I am using the following code: function wc_empty_cart_redirect_url() { return 'custom-url-EN'; } add_filter( 'woocommerce_return_to_shop_redirect', 'wc_empty_cart_redirect_url' );
Sintomi:
I have not found any documentation that truly helps.
Domande:
How can I set a different label and URL for each language in the 'Return to the shop' snippet?
ICL_LANGUAGE_CODE è una funzione deprecata e non andrebbe mai usata.
Il secondo snippet dovrebbe funzionare.
Tieni presente che il supporto non copre il codice custom come questo, posso solo darti delle indicazioni su come raggiungere il risultato voluto ma non possiamo scrivere del codice ex-novo.
Vanno bene le tue indicazioni ma ti chiedo di aiutarmi su 2 cose:
1) Per tua esperienza che differenza esiste tra l'uso di wpml_current_language o wpml_object_id? Nel mio caso quale conviene?
2) È possibile che usando wpml_current_language (o attivando lo snippet) avvenga in modo automatico l'aggiornamento dei permalink? Chiedo questo perché è successo.
wpml_current_language ritorna la lingua che stai usando in quel momento (la lingua corrente, appunto) mentre wpml_object_id ritorna l'ID del post nella lingua scelta, quindi fanno proprio 2 cose diverse.
WPML aggiorna i permalink dei link interni, se il contenuto viene tradotto. Non c'è una documentazione.
Nel tuo caso, lo snippet rileva qual è la lingua in uso e ritorna il permalink che hai indicato nello snippet stesso, non c'è nessun aggiornamento dei permalink.