• Resolved therealgilles

    (@chamois_blanc)


    Hi, I know it’s kind of a recurring topic but other solutions I have found do not seem to apply to my case.

    95% of the time I am not able to remove items from the cart on the cart page (using ajax) on one of my sites. I do not use caching (varnish is off on the server, no caching plugins) because every time I’ve tried, I had numerous problems.

    It seems to be a session issue but I am having trouble figuring out the culprit. Below is a log extract where you can see the remove_cart_item function being called, the item being removed from the cart, but then when set_session is called, the cart total is back to 25 and the cart is not empty anymore:

    [29-Jun-2018 20:18:39 UTC] remove_cart_item
    [29-Jun-2018 20:18:39 UTC] set_session
    [29-Jun-2018 20:18:39 UTC] ... total = 0
    [29-Jun-2018 20:18:39 UTC] get_cart_for_session
    [29-Jun-2018 20:18:39 UTC] ... total 0
    [29-Jun-2018 20:18:39 UTC] ... get_calling_function_name = get_cart_for_session => set_session => calculate_totals => apply_filters => do_action => do_action => remove_cart_item => update_cart_action => apply_filters => do_action
    [29-Jun-2018 20:18:39 UTC] persistent_cart_update
    [29-Jun-2018 20:18:39 UTC] ... updating
    [29-Jun-2018 20:18:39 UTC] get_cart_for_session
    [29-Jun-2018 20:18:39 UTC] ... total 0
    [29-Jun-2018 20:18:39 UTC] ... get_calling_function_name = get_cart_for_session => persistent_cart_update => apply_filters => do_action => do_action => set_session => calculate_totals => apply_filters => do_action => do_action
    [29-Jun-2018 20:18:39 UTC] set_session
    [29-Jun-2018 20:18:39 UTC] ... total = 25.00
    [29-Jun-2018 20:18:39 UTC] get_cart_for_session
    [29-Jun-2018 20:18:39 UTC] ... total 25.00
    [29-Jun-2018 20:18:39 UTC] ... get_calling_function_name = get_cart_for_session => set_session => apply_filters => do_action => do_action => calculate_totals => get_cart_from_session => apply_filters => do_action => do_action
    [29-Jun-2018 20:18:39 UTC] ... key = e82d1ab455aad7057ffcc0ea799eb4e3

    If someone could tell me how to go about debugging session issues, that would be tremendously helpful. Thank you!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter therealgilles

    (@chamois_blanc)

    I think I figured it out. Along with the remove_cart_item ajax request, there was a wcmenucart ajax request firing too early and interfering with the empty of the cart.

    I change the wcmenucart JS code to only fire on updated_wc_div/update_checkout events, when the cart status should be done being updated.

    PS: The WP Menu Cart (Pro) plugin must have a similar issue.

    Thread Starter therealgilles

    (@chamois_blanc)

    Mentioning that I had a similar issue on the checkout page. I have custom add to cart and remove from cart buttons triggering ajax requests. I needed the menu cart item update to wait for the updated_checkout event, instead of the update_checkout event.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Problem with removing item from cart’ is closed to new replies.