WPML
Status
Resolved
Reported for
WPML Multilingual & Multicurrency for WooCommerce 5.3.9
Resolved in
WPML Multilingual & Multicurrency for WooCommerce 5.5.3
Topic tags
Bug, WCML

Overview of the issue

You may experience an ERR_TOO_MANY_REDIRECTS error when using WPML Multilingual & Multicurrency for WooCommerce while setting product permalinks to Shop base with category.

This issue occurs when products are set to Translatable – use translation if available or fallback to default language, and product categories are also translatable. When switching to a secondary language, the translated product URL fails to resolve correctly, causing an infinite redirect loop.

Workaround

Please, make sure of having a full site backup of your site before proceeding.


  • Open your theme’s function.php file.

  • Add the following code:
    add_filter( 'wc_product_post_type_link_product_cat', 'custom_modify_product_cat', 10, 3 );
    
    function custom_modify_product_cat( $primary_term, $terms, $post ) {
    	// Example: Replace the primary term if the product has a specific category
    	if ( $post->post_type === 'product' ) {
    		foreach ( $terms as $term ) {
    			$termid = apply_filters( 'wpml_object_id', $term->term_id, $term->taxonomy, TRUE  );
    			$term = get_term( $termid, $term->taxonomy );
    			return $term;
    		}
    	}
    	return $primary_term;
    }

All known issues →