Panoramica del problema
Se utilizzi il tema Woodmart insieme a WPML, potresti riscontrare un problema per cui la traduzione di un Layout prodotto si blocca e non viene completata. Inoltre, troverai un errore simile:
Call to a member function get_gallery_image_ids() on null .../wp-content/themes/woodmart/woocommerce/single-product/product-image.php:27
Documentazione attuale: I layout prodotto di WoodMart si traducono con WPML. Leggi come fare in Traduci un negozio WoodMart con WPML.
Soluzione alternativa
Questo problema è stato risolto in WoodMart 8.0.2. L'aggiornamento risolve il problema sul tuo sito, quindi hai bisogno di questa soluzione alternativa solo se non puoi ancora aggiornare.
Assicurati di avere un backup completo del sito prima di procedere.
- Apri il file functions.php del tuo tema.
- Aggiungi il seguente snippet:
add_action( 'woocommerce_before_template_part', function () { global $product; if ( wp_is_json_request() && ! $product ) { $random_product = new WP_Query( array( 'posts_per_page' => '1', 'post_type' => 'product', ) ); while ( $random_product->have_posts() ) { $random_product->the_post(); $product_id = get_the_ID(); } wp_reset_postdata(); $product = wc_get_product( $product_id ); } } ); - Svuota la cache e traduci nuovamente il layout del prodotto.
- Vai su Bacheca di WordPress -> WoodMart -> Patcher.
- Seleziona la patch numero 618307.