Cashier product search autocomplete field stops working when Varnish in use

Created on 14 March 2019, over 5 years ago
Updated 16 March 2023, over 1 year ago

Problem/Motivation

UPDATE: Further testing on the initial issue revealed that the autocomplete field is only failing when Varnish is in running. I've updated the issue to reflect.

When Varnish is in running, the cashier interface autocomplete product search stops working (example gif below). So does the product search when manually creating orders via "Commerce > Orders > Create a new order" and using the Point of Sale order type. The default order type works fine.

Other autocomplete fields DO work. For instance, I went into Promotions and used the autocomplete field to set a promotion condition on a specific product. Searching for the product in this instance worked fine.

If I disable Varnish, the autocomplete starts working again as it should. Error logs don't show anything, so I can't give any more details other than that.

Remaining tasks

Diagnose and fix the broken autocomplete product search field when Varnish is running.

πŸ› Bug report
Status

Needs review

Version

2.5

Component

Code

Created by

πŸ‡¨πŸ‡¦Canada Hubbs

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡¨πŸ‡­Switzerland Lukas von Blarer

    I'm facing a similar issue, but not only with varnish. I have the issue under varnish and nginx. I think we are not setting cookies properly in this module. Here are the two occurrences of setcookie:

    setcookie($this->cookieName, json_encode($this->cashiers),
          time() + $this->cookieDuration, '/');

    setcookie('commerce_pos_register', $register->id(), time() + 31557600, '/');

    In my opinion we should be setting them as HttpOnly and Secure:

    setcookie($this->cookieName, json_encode($this->cashiers),
          time() + $this->cookieDuration, '/', '', TRUE, TRUE);

    setcookie('commerce_pos_register', $register->id(), time() + 31557600, '/', '', TRUE, TRUE);

    This way the cookies persist across requests.

    I'm not exactly sure if we are facing the same issue. So sorry in case I'm hijacking this issue.

  • Status changed to RTBC over 1 year ago
  • πŸ‡¨πŸ‡­Switzerland Lukas von Blarer

    This patch fixes the issue for me.

  • Status changed to Needs review over 1 year ago
  • πŸ‡¨πŸ‡­Switzerland Lukas von Blarer

    Ok, I understood why we are using cookies: We want to store this data across multiple session on the same device.

Production build 0.69.0 2024