Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
query getSanityRewards {
  RewardList(id: "reward-list-singleton") {
    rewardCategories {
      _id
      label {
        en
      }
      rewards {
        ... on Reward {
          # Sanity ID of the reward
          _id
          # Loyalty Engine ID to be used in the Loyalty Engine query if needed
          loyaltyEngineId
          # Reward content to display to the user (name, image, description...)
          name {
            en
          }
          image {
            en {
              asset {
                url
              }
            }
          }
          description {
            enRaw
          }
          # Here we add the rules we want to check for the rewards
          # e.g., LoyaltyPoints (reward points cost), RewardPrice (reward money price),
          # SubtotalSpend (minimum subototal to spend for redeeming the reward)
          ruleSet {
            ... on LoyaltyPoints {
              points
            }
            ... on RewardPrice {
              price
            }
            ... on SubtotalSpend {
              minimumSpend
            }
          }  # Add more ruleSets as needed here (e.g. FirstOrderOnly, LoyaltyBetweenDates, etc)
# Benefit of the reward, it can be either a Combo, Item, OfferDiscount# See the screenshot below for how get the list of #available orruleSet Pickerfrom GraphQL Playground
        # e.g., OfferDiscount}
(It can be a discount for the whole cart or    # Benefit of the reward, it can be #either a discountCombo, forItem, aOfferDiscount
specific product)         # or incentivesPicker
{          #   e.g.. on, OfferDiscount {(It can be a discount for the whole cart or 
    discountType      # a discount for a specific product)
  discountValue               discountProduct incentives {
                ... on ItemOfferDiscount {
              discountType
   name {          discountValue
          en    discountProduct {
             }   ... on Item {
          }        name {
       ... on Combo {          en
        name {         }
           en     }
             }   ... on Combo {
          }        name {
     }             }  en
        }          }
# Reward redemption method available           redemptionMethod }
         # Here we can get the}
needed PLUs by looking for a specific vendor     }
     # e.g., Partner constant PLU }
         vendorConfigs {# Reward redemption method available
        partner {
              _type  redemptionMethod
          # Here we can get the needed PLUs by looking for a specific vendor
          # e.g., Partner constant PLU
    constantPlu      vendorConfigs {
       pluType     partner {
       }       _type
   }         }  constantPlu
    }     }   } }
 pluType
            }
          }
        }
      }
    }
  }
}

Expand
titleGetting the list of ruleSets from GraphQL Playground

To get list of ruleSet available, navigate to https://czqk28jt.apicdn.sanity.io/v1/graphql/dev_bk_aq/default, and search for “ruleSet” in the Schema explorer as seen here:

image-20240813-035328.pngImage Added

...

Querying Loyalty Engine

Info

GraphQL URL (Playground Available): https://euc1-dev-bk-loyalty-middleware.rbictg.com/graphql

...