Shopify / ui-extensions

MIT License
267 stars 35 forks source link

Customer Note not available on POS Extension via useCartSubscription #2265

Closed ljclark closed 2 months ago

ljclark commented 2 months ago

Please list the package(s) involved in the issue, and include the version you are using

  "dependencies": {
    "react": "^18.0.0",
    "@shopify/ui-extensions": "2024.4.x",
    "@shopify/ui-extensions-react": "2024.4.x"
  },
  "devDependencies": {
    "@types/react": "^18.0.0",
    "react-reconciler": "0.29.0"
  }

import { Tile, useApi, reactExtension } from '@shopify/ui-extensions-react/point-of-sale';

Extension api_version = "2024-07"
POS App version 9.15.0

Describe the bug

When subscribing to cart updates on a Shopify POS extension, the customer.note property is no longer available to access as it should be.. It always returns undefined when trying to fetch the data.

According to this set of docs, it should be available to access.

There is one exception to this - outlined below.

[!IMPORTANT]
This was working as normal until the 14th August 2024, but it's now stopped.

  api.cart.subscribable.subscribe((cart) => {
    const customerNote = cart.customer.note;
      ... // customerNote is always 'undefined'
  });

Steps to reproduce the behavior:

  1. Subscribe to the cart changes in your POS extension
  2. Assign a customer to the cart that has a note
  3. Output the customer.note property somewhere within your POS tile - it'll return as null/undefined

The only way I can get this to work is if you do the following:

  1. Subscribe to the cart changes in your POS extension
  2. Assign a customer to the cart that does not have a note
  3. Add a note to the customer within the POS device
  4. Output the customer.note property somewhere within your POS tile - it'll return the note
  5. However, if you then go back and update the newly added customer note, it will continue to render the old note added in Step-3.

Even when explicitly setting the customer on the cart via api.cart.setCustomer, it doesn't fetch the note.

Expected behavior

The customer.note property should return the note at all times based on the customer.note value that exists at the time of accessing that customer property, irrespective of when and how the customer note was added.

NathanJolly commented 2 months ago

Thanks for this report! The issue will be resolved in 9.17.0