Skip Navigation

Open

Reported for: WooCommerce Multilingual & Multicurrency 5.3.9

Topic Tags: Bug, WCML

Overview of the issue

You may experience an ERR_TOO_MANY_REDIRECTS error when using WooCommerce Multilingual & Multicurrency 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;
    }
    

2 Responses to “WooCommerce Multilingual - "Too Many Redirects" Error When Using "Shop Base with Category" Permalinks”

  1. I am using permalinks with custom base “/product/” and have exactly the same issue. I get infinite loop crashes and it only resolves if I resave permalinks.

    The fault lies in the fact that there is an error in the htaccess that direct to secondary language (loop)

    • Hi, Thanks for the feedback, The ERR_TOO_MANY_REDIRECTS error could be explained by many scenarios, and the behavior you’re describing appears to differ slightly from what’s addressed in this erratum.

      If you’re still encountering the issue, please open a support ticket so we can investigate further.

Leave a Reply

Please stay on topic and be respectful to others. If you need help with issues not related to this post, use our Support Forum to start a chat or submit a ticket.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>