Home Forums WoodMart support forum Issue with megamenu and ajax

Issue with megamenu and ajax

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #681811

    grcp
    Participant

    Hi Support,

    I’m using the megamenu along with Ajax for the shop.
    I’ve noticed an issue: when I click on a category in the megamenu, the menu does not close automatically.

    Do you have any suggestions?

    #681914

    Hung Pham
    Keymaster

    Hi grcp,

    Thanks for reaching to us.

    Unfortunately, there is no such an option.

    Regards,
    Hung PD

    #681918

    grcp
    Participant

    Is there really no other option? It doesn’t make sense that this is not supported. There are many themes out there that provide this functionality without causing issues with AJAX. Do I really have to disable AJAX – and make the website slower – just to make the Mega Menu work properly? This shouldn’t be the case.

    Since there is already an option for AJAX loading in the shop, there should also be proper support for the Mega Menu. In other themes, when the user clicks on a category, the menu closes automatically, and the new category page is loaded. Otherwise, the user gets the impression that the site is “freezing,” because the Mega Menu remains open while the new page with the products has already loaded in the background.

    Please take a look at this, as it directly affects the user experience and is very important for the website.

    #682042

    Hung Pham
    Keymaster

    Hi grcp,

    Thank you for your feedback and for providing a detailed description of the situation. You are absolutely right — for users, it may look like the site is “freezing” when the menu remains open after clicking on a category.

    At the moment, unfortunately, automatic closing of the Mega Menu when using AJAX loading is not supported. This is a limitation of the current logic.

    However, we can provide you with a custom code snippet that will disable AJAX loading in this specific case and ensure that the menu closes correctly when navigating to a category:

    Paste the code into Theme Settings > Custom JS > Global JS

    add_filter('woodmart_ajax_links', function () {
    	return '.wd-nav-product-cat a, .wd-page-wrapper .widget_product_categories a, .widget_layered_nav_filters a, .woocommerce-widget-layered-nav a, .filters-area:not(.custom-content) a, body.post-type-archive-product:not(.woocommerce-account) .woocommerce-pagination a, body.tax-product_cat:not(.woocommerce-account) .woocommerce-pagination a, .wd-shop-tools a:not([rel="v:url"]), .woodmart-woocommerce-layered-nav a, .woodmart-price-filter a, .wd-clear-filters a, .woodmart-woocommerce-sort-by a, .woocommerce-widget-layered-nav-list a, .wd-widget-stock-status a, .widget_nav_mega_menu a, .wd-products-shop-view a, .wd-products-per-page a, body[class*="tax-pa_"] .woocommerce-pagination a';
    });

    This way, the menu will close properly, and users will not have the impression that the page is “freezing.”

    Regards,
    Hung PD

    #682127

    grcp
    Participant

    Hi Hung,

    I’ve added the code, but it doesn’t seem to be working.
    Is this code correct?

    #682239

    grcp
    Participant

    Any update ?

    #682253

    Hung Pham
    Keymaster

    Hi grcp,

    Sorry for typo.

    Please remove above code from JS section and try to add these to the child theme functions.php file to fix this

    Regards,
    Hung PD

    #682257

    grcp
    Participant

    Thank you mate ! Problem solved !

Viewing 8 posts - 1 through 8 (of 8 total)