• Resolved odyss31

    (@odyss31)


    Hello, i use litespeed cache plugin for my eshop. I have enabled delay javascript, but i have problem with add to cart button. I use block theme for my eshop and the functionality of the add to cart button is to use ajax to update the cart and minicart. When i enable javascript delay and i open my eshop on a browser with incognito mode, if i click on the add to cart button the first time it reloads the page. After that it works as it should be with ajax. I found out that the problem was that the woocommerce js file responsible for the ajax of the button had the following if if(“undefined”==typeof wc_add_to_cart_params)return!1; wc_add_to_cart_params is added with wp_localize_script. When javascript delay is enabled wc_add_to_cart_params is undefined until a reload happens. It is not the first time i encounter this problem when there is a wp_localize_script connected to a js file. Up until now the only solution i found is to modify the js file which is wrong because if an update happens then my modifications are gone. So my question is whether there is a solid solution when dealing with javascript files that are connected with wp_localize_script. I already tried excluding js files from delay (cart-fragments.js, cart-fragments.min.js, cartWidget.js), i also enabled the option Vary for Mini Cart.

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Plugin Support litetim

    (@litetim)

    @odyss31
    We are sorry for the problems you encounter.
    Please create a ticket by sending an email with:
    – link to this topic
    – ask to be assigned to a developer
    – to address support at litespeedtech.com

    Thank you!

Viewing 1 replies (of 1 total)

The topic ‘Problems with scripts that are connected to wp_localize_script’ is closed to new replies.