Bug in WooCommerce_Widget_Product_Categories (3 posts)

  1. Denis V (Artprima)
    Posted 3 years ago #

    There is a bug in WooCommerce when using it with WPML and language indication way via ?lang=XX parameter.

    The bug can be found here:

    <script type='text/javascript'>
                /* <![CDATA[ */
                    var dropdown = document.getElementById("dropdown_product_cat");
                    function onCatChange() {
                        if ( dropdown.options[dropdown.selectedIndex].value !=='' ) {
                            location.href = "<?php echo home_url(); ?>/?product_cat="+dropdown.options[dropdown.selectedIndex].value;
                    dropdown.onchange = onCatChange;
                /* ]]> */

    echo home_url() produces for example http://site.com/?lang=es and then you add /?product_cat=XXXX resulting http://site.com/?lang=es/?product_cat=XXXX

    Can be seen here:

    I consider it a bug because you may not rely on home_url() this way since it may be filtered by plugins (as in this case).

  2. helgatheviking
    Posted 3 years ago #

    the FAQ requests that you report bugs at the WooCommerce GitHub repository. Unlikely the WC devs will see your report here.

  3. Denis V (Artprima)
    Posted 3 years ago #

    Yeah, I get it. Anyway, changing url structure to http://site.com/lang_code/ solves the problem.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WooCommerce
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic