Support » Plugin: Headless WooCommerce powered by CoCart » Incompatibility with Advanced Woo Search PRO

  • Resolved Estian Hough

    (@divspot)


    Good day,

    We’re having issues with our installation of CoCart Lite; when an AJAX search is performed (Advanced Woo Search PRO) the response results in GUEST user carts being cleared.

    We’ve figured out that this is because the WooCommerce conditional (/includes/class-wc-cart-session.php -> maybe_set_cart_cookies()) succeeds (no headers from the “wp” hook?) and determines that the cart is empty, which results in the following:
    $this->set_cart_cookies( false );

    This then results in CoCart Lite destroying the cart (/includes/class-cocart-session-handler.php -> set_customer_cart_cookie()).

    What can we do to resolve this incompatibility/issue?
    Looking at Chrome dev tools I can see that headers are sent along with the AJAX request, why then is the cart cleared in the “wp” hook?

    Versions:
    Advanced Woo Search PRO: 2.24
    CoCart Lite: 2.9.2
    WooCommerce: 4.8.0
    WordPress: 5.6

    Regards,
    Estian

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

Viewing 15 replies - 1 through 15 (of 15 total)
  • Plugin Author Sébastien Dumont

    (@sebd86)

    @divspot Can you share the steps you take so I can replicate this? Because I am not seeing any issues on the frontend that this search plugin is designed for.

    Thread Starter Estian Hough

    (@divspot)

    Hi Sébastien,

    Certainly.

    1. Open https://isabellagarcia.co.za
    2. Add any item (from any page) to your cart (as a guest).
    3. Input a search keyword using the header “search icon”, await an AJAX response.
    4. Refresh the page or open a different page.
    5. Notice that the cart has been cleared.

    If you look at the headers (as is provided with Chrome dev tools) you’ll be able to notice that it sends cookie data in the response that clears the cart.

    Please let me know if you need more information.

    Regards,
    Estian

    Thread Starter Estian Hough

    (@divspot)

    Hi Sébastien, @sebd86

    For some additional information see below.

    I’ve noted also that the AJAX search sends the correct WooCommerce cart data in the headers as it does when adding an item to the cart. I just don’t see what is different between an “add to cart” AJAX request and an AJAX “search” request in terms of the request data?

    What is the purpose of the code in?
    /includes/class-cocart-session-handler.php -> set_customer_cart_cookie())
    When $set = false the following is run:

    // If cookies exists, destroy it.
    			if ( isset( $_COOKIE[ $this->_cookie ] ) ) {
    				$this->cocart_setcookie( $this->_cookie, '', time() - YEAR_IN_SECONDS, $this->use_secure_cookie(), $this->use_httponly() );
    				unset( $_COOKIE[ $this->_cookie ] );
    			}

    This function is a twin of the WooCommerce class-wc-session-handler.php -> set_customer_session_cookie(...) function, yet the WooCommerce function does not delete the cart on $set === false.

    Plugin Author Sébastien Dumont

    (@sebd86)

    Thank you for providing the steps. I was able to replicate the issue.

    The purpose of destroying the cookie is for when a guest customer turns into a registered customer by authenticating. Without destroying the cookie first, the cart does not return correctly for the registered customer when the response returns.

    This should not be affecting guest customers as the cookie is only destroyed first before creating a new one when a customer is authenticated.

    Plugin Author Sébastien Dumont

    (@sebd86)

    I tested the steps locally with the free version of the plugin and there was no issue as a guest customer. The cart did not clear. The problem is with the Pro only so it might be best to ask them for support to find out what the difference is between the two search plugins.

    Thread Starter Estian Hough

    (@divspot)

    Hi Sébastien @sebd86,

    Thank you for your response & feedback.
    I will look into the free version of the “Advanced Woo Search” plugin and test.

    Unfortunately the plugin’s developer has not yet responded and we are a little stuck in the mud.
    By looking at the AJAX search request headers I don’t understand why it would destroy the cart – it does indeed send cart data to the server.

    I appreciate all of your assistance.

    Regards,
    Estian

    Thread Starter Estian Hough

    (@divspot)

    Hi Sébastien Dumont (@sebd86),

    My colleague and I have done additional testing on our side and have confirmed that with the CoCart Lite plugin enabled the Advanced Woo Search PRO version does “clear the cart“.
    The issue here however is not that the Advanced Woo Search Pro is performing the clear but rather when the CoCart Lite plugin is enabled the plugin reports incorrectly that there are no items in the cart.
    If I perform a search using Advanced Woo Search PRO with the CoCart Lite plugin disabled the plugin correctly indicates that there are items in the cart.
    If however I enable the CoCart Lite plugin and perform the same search the response from that indicates that the cart was empty, there must be something in the CoCart Lite plugin that is altering this.

    Please could you advise?

    Thank you for your continued assistance.

    Regards,
    Estian

    Plugin Author Sébastien Dumont

    (@sebd86)

    As I stated before @divspot

    I tested your steps locally with the FREE version and was NOT ABLE to replicate the issue so there is a difference between the FREE and the PRO version of “Advanced Woo Search” plugin.

    Which is why I said for you to contact the developers of Advanced Woo Search as you are a customer of theirs and should get support from them.

    There is nothing in there documentation that explains to a developer how this can be triggered.

    Until we are able to identify the difference between the two versions of the plugin I can’t help.

    I certainly cannot alter set_customer_cart_cookie() as it will break CoCart.

    I hope the developers of “Advanced Woo Search” can give some insight and respond soon so that this issue can be resolved.

    Sorry that I cannot be of much help at this time.

    Plugin Author Sébastien Dumont

    (@sebd86)

    I have contacted the developers also and forwarded this issue.

    Thread Starter Estian Hough

    (@divspot)

    Sébastien Dumont (@sebd86),

    Thank you for your response.

    I understand what you are saying – it is the PRO version causing the issue.
    We’ve been busy investigating the code to try and find out why.
    Unfortunately the plugin developer does not seem interested in responding.

    Regards,
    Estian

    Plugin Author Sébastien Dumont

    (@sebd86)

    Let me know if the developer does respond and I will re-open this issue.

    Thread Starter Estian Hough

    (@divspot)

    Sébastien Dumont (@sebd86),

    The Advanced Woo Search PRO plugin developer has responded and advised how to fix the issue. He also noted that a future update will include the fix.

    Thank you for all of your assistance.

    Regards,
    Estian

    Plugin Author Sébastien Dumont

    (@sebd86)

    I’m glad the developer got back to you and that a fix is under way. 😀

    Plugin Author Sébastien Dumont

    (@sebd86)

    Advanced Woo Search (Free) v2.26 includes a fix now so it is compatible with CoCart. I don’t know if the Pro version has a fix applied yet. Maybe you can tell me.

    Thanks.

    Thread Starter Estian Hough

    (@divspot)

    Sebastien Dumont @sebd86,

    Thank you for your response.
    I apologize for the very delayed response from my side.

    The issue has been fixed for us.
    This ticket can certainly be closed!

    Thank you,
    Estian

Viewing 15 replies - 1 through 15 (of 15 total)
  • The topic ‘Incompatibility with Advanced Woo Search PRO’ is closed to new replies.