Skip to main content

Yotpo Questions

Overviewโ€‹

This module provides a system for fetching, grouping, and preparing product questions and answers from Yotpo for display in our UI. It handles both single products and bundles.

Key features:

  • Fetches data from Yotpo based on Shopify product IDs.
  • Groups products of similar style as this isn't handled automatically from Yotpo.
  • Caches requests efficiently to reduce network overhead.

Main Function: getYotpoQuestionsโ€‹

Purposeโ€‹

Orchestrates the entire process of retrieving and grouping product questions.

Flowโ€‹

The flow differs depending on the type of product. If the product has a fabric we get all sibling product IDs. If the product does not have a fabric we get product IDs using the getYotpoProductInfo function.

Once we have all relevant IDs we:

  1. Fetch all questions per ID
  2. Group all questions together (Yotpo doesn't do this for us)
  3. Sort by newest to oldest
  4. Return the processed response

Bundles are handled by the getYotpoProductInfo function to grab all relevant IDs.


Supporting Functionsโ€‹

fetchYotpoQuestionsโ€‹

Fetches questions for one or multiple product IDs.

getQuestionByIdโ€‹

Makes direct calls to Yotpo's API for questions by product ID, supporting both simple and filtered queries.

getAdditionalProductsDataโ€‹

Used when the base product has a fabric to get all sibling products.


Error Handling & Cachingโ€‹

  • All external API calls are wrapped with error capture and logging via Sentry.
  • Responses are cached with appropriate cache strategies to reduce network load.

Usage Notesโ€‹

  • This function is called in api.yotpoQuestions.tsx.
  • Upon landing on the PDP route, the loader is called passing the args.
  • The loader calls the getYotpoQuestions function which handles the flow of fetching questions for all siblings and grouping them.
  • Bundled products contain questions for each separate as well as the bundle itself.

Supporting Documentsโ€‹

The below are useful for cross functional knowledge share: