Support » Plugin: LiteSpeed Cache » checkout/àdd-to-cart executed twice

  • Resolved cbdfactum.com

    (@cbdfactum)


    The above test page should add only one product id 160 but when LiteSpeed is activated the product is added twice because the page is opened twice.

    After testing around and reading the log files I saw that it maybe LiteSpeed and indeed, when I deactivate LiteSpeed than it works.

    As this should be a plugin we cannot deactivate LiteSpeed and it must work on any system, even when LiteSpeed is activated. How can we prevent LiteSpeed to open the page once.

    Once the page was opened then it works but this is not a solution as it must work for the very first time.

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

Viewing 13 replies - 1 through 13 (of 13 total)
  • CacheCrawler

    (@serpentdriver)

    For testing, disable Guest Mode. Purge Cache and try again.

    Plugin Support qtwrk

    (@qtwrk)

    Did you just directly access the URI like you posted ?

    instead of click “add to cart” kind of button ?

    Thread Starter cbdfactum.com

    (@cbdfactum)

    Yes, this URL is called as you see it in the plugin because it adds a product – triggered by a certain situation – directly into the shopping cart. When I add for example &quantity=25 then the shopping cart has 50 products of the item.

    Then wp_redirect($addToShoppingCart) is called.

    Did you just directly access the URI like you posted ?

    CacheCrawler

    (@serpentdriver)

    @cbdfactum

    The issue you describe is a logical consequence of the guest mode. If a page is requested first time guest mode loads page again. If the first request goes directly to a URL that adds items directly to the cart, it is logical that number of items are doubled. Either you disable guest mode or @qtwrk finds a way to disable guest mode if a certain link/Url is requested.

    Thread Starter cbdfactum.com

    (@cbdfactum)

    OK, I understand. I think you agree I can’t do much about it as it’s a plugin and the plugin cannot really force the WordPress webmaster to set the settings so it works.

    I confirm that when I disable the Guest-Mode then the it works as expected.

    Any other suggestion? I didn’t find a way how to set the quantity in the WooCommerce to 1 – this would make it immune against any multiple calls.

    CacheCrawler

    (@serpentdriver)

    Be patient, maybe @qtwrk has any idea how to solve it.

    Thread Starter cbdfactum.com

    (@cbdfactum)

    Maybe adding a parameter like liteSpeedGuestMode=off would solve this quickly and reliable as the parameter would be ignored by other modules or could be then removed from the request.

    CacheCrawler

    (@serpentdriver)

    This would be the idea behind a possible solution. In normal condition without a fullpage HTTP cache this could be done easily, but if a page is cached there is no more PHP interpreter that can be executed. Full page cache means the output is plain HTML like it is if you use browser function to store a requested page local on your computer. It is possible, of course, but to solve it easily cache and the function for guest mode must be disabled whenever a request has certain parameter or $_GET query like it is used for adding an item to cart.

    Again, maybe @qtwrk has any idea.

    Plugin Support qtwrk

    (@qtwrk)

    please try add this to your wp-config.php , next line after <?php

    code:

    if (strpos($_SERVER['REQUEST_URI'], "checkout") !== false){
    define( 'LITESPEED_CONF', true );
    define( 'LITESPEED_GUEST', false );
    }

    then purge all and try again.

    Thread Starter cbdfactum.com

    (@cbdfactum)

    If I understand it correctly this is not the solution I can apply successfully! I cannot tell each client who installs the plugin to manipulate its wp-config.php.

    I need a solution which stops LiteSpeed to request sites twice.

    If I understand it correctly this is not the solution I can apply successfully!

    It is a solution that you can apply successfully, but it is up to LiteSpeed to add this filter as default part of the plugin, although this need is very very, again very very very rare.;)

    Plugin Support Hai Zheng⚡

    (@hailite)

    @cbdfactum In v4.7-a20, there is litespeed_guest_off=1 added. You can use this in your query string to bypass guest mode for that link.

    Thread Starter cbdfactum.com

    (@cbdfactum)

    Thank you Hai!

    Even the current version is 4.6 we are happy that LiteSpeed reacted so fast and we know it’s just question of few weeks until the new version will be deployed and then it’s only the responsibility of the webmaster to have the most current version installed.

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘checkout/àdd-to-cart executed twice’ is closed to new replies.