Skip Navigation

Resolved

Resolved in: 4.7.2

Overview of the issue

When you use WooCommerce’s products shortcode and include the category attribute like so:
[ products category="product_category_slug" ], the translated page will not show up the products assigned to that product category.

Workaround

A temporary workaround should be to:
Go to wp-content/plugins/woocommerce-multilingual/classes/shortcodes/class-wcml-wc-shortcode-product-category.php line 43 and find
->map( function ( $category ) { return get_term( $category, 'product_cat' ); } );
Replace it with
->map( function ( $slugOrId ) {
if ( is_numeric( $slugOrId ) ) {
return get_term( $slugOrId, 'product_cat' );
}
return get_term_by( 'slug', $slugOrId, 'product_cat' );
} );

12 Responses to “WooCommerce products shortcode does not work on the translated page when category attribute is used”

  1. sono andato su /Divi/includes/builder/module/Shop.php ma non trovo questa stringa da nessuna parte:
    if ( et_()->includes( array_keys( $wc_custom_views ), $type ) ) {
    $wc_custom_view = “{$wc_custom_views[ $type ]}=”true””;
    }

    • Ciao, scusa ma non capisco a cosa ti riferisci. La stringa da modificare è in wp-content/plugins/woocommerce-multilingual/classes/shortcodes/class-wcml-wc-shortcode-product-category.php mentre tu mi parli di Divi. Puoi essere più specifico?

      • Ciao, scusa per la precedente risposta. Il fix specifico per Divi è stato cambiato e sostituito da questo più generico e valido per ogni tema.
        Potresti testarlo e vedere se funziona?

    • Ciao, cosa esattamente non è chiaro nella spiegazione? Devi aprire il file wp-content/plugins/woocommerce-multilingual/classes/shortcodes/class-wcml-wc-shortcode-product-category.php e sostituire una stringa. Per aprire il file puoi andare in Plugin > Editor plugin oppure aprirlo via FTP.

  2. Hello,

    This fix worked with our Genesis Custom build child theme!

    Do you have any idea when this wil be fixed in feature releases because we can not update the plugin now.

    Kind regards,

    Joep

  3. Ciao Laura, scusami ma sono un nuovissimo utente wpml e abbi pazienza ma essendo più designer che programmatore queste sottigliezze mi creano un certo disagio.
    Comunque utilizzando l’editor del plug in non trovo lo stesso percorso citato e volendo evitare di passare da ftp chiedevo se era possibile avere il percorso alternativo. Grazie