Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

Non-technically explanation

  • The PLU item needs to exist in the restaurant PLU data (PLU with price)

  • If the item doesn't exist in the selected store data (when using the Whitelabel app) the app will alert the user that the item is unavailable (when the item is added in the cart preview or added inside the checkout, for example)

  • The restaurant data is not available to be configured inside Sanity. This needs to be done somewhere else.


Analysis

For each restaurant, we'll have the restaurantPosData returned from the usePosDataQuery. This will be where we get the prices object for all PLUs available for the user selected store.

At some point in the application, we'll check if an item (in the menu or the item added to the cart) is an available item checking his PLU against the PLU prices object. If this PLU is not found the application will show a modal alerting the user that the item is not available for the selected store (image above).

Some components and hooks will work together in this workflow:

  • Cart Page → The page is responsible for showing the OrderUnavailableModal

    • Path: src/pages/cart/index.tsx

    • usePriceOrder: This hook will pass the unavailableCartEntries and the cart will know when to show the modal

      • useUnavailableCartEntries: This hook is used inside the usePriceOrder, returning the unavailableCartEntries

        • useGetUnavailableItemsFromMenu: This hook will filter/return the unavailable items (with data = null)

          • useCartEntriesMenuObjects: This hook will use the asyncGetMenuObject from useMenuContext to get the menu object items

            • The returned data from this context will be filtered using the applyFiltersForAvailability method

            • This method will check if the item is available using the itemIsAvailable (for type “Item”) that uses the vendorConfigIsAvailable method

            • Finally, the vendorConfigIsAvailable will use the pluIsAvailable to look inside the restaurant prices PLU data looking for the PLU for the desired item. If the PLU is not found there, the item is considered UNAVAILABLE

            • OBS: The applyFiltersForAvailability will receive the prices object from useStoreUtils that will use the usePosDataQuery:

  • No labels

0 Comments

You are not logged in. Any changes you make will be marked as anonymous. You may want to Log In if you already have an account.