Microsoft Azure PlayFab logo
    • Multiplayer
    • LiveOps
    • Data & Analytics
    • Add-ons
    • For Any Role

      • Engineer
      • Designer
      • Executive
      • Marketer
    • For Any Stage

      • Build
      • Improve
      • Grow
    • For Any Size

      • Solo
      • Indie
      • AAA
  • Runs on PlayFab
  • Pricing
    • Blog
    • Forums
    • Contact us
  • Sign up
  • Sign in
  • Ask a question
  • Spaces
    • PlayStream
    • Feature Requests
    • Add-on Marketplace
    • Bugs
    • API and SDK Questions
    • General Discussion
    • LiveOps
    • Topics
    • Questions
    • Articles
    • Ideas
    • Users
    • Badges
  • Home /
  • API and SDK Questions /
avatar image
Question by daksshbhambre · Jun 06 at 01:15 AM · unity3dgame managerIn-Game Economy

List Store in playfab

So i am new to playfab and i want to make a store in my unity game where you can see the name of the item and the cost of the item like a list scroll view . But i don't know how to get the display name and the price from the playfab store and i also want to list the item. I tried searching for tutorial but no luck ): please tell me the code used to do this.

Comment

People who like this

0 Show 0
10 |1200 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
Best Answer

Answer by Gosen Gao · Jun 06 at 08:09 AM

You can use API GetStoreItems to get the item’s info for a specific store. But it is not include the DisplayName, you may need to call API GetCatalogItems to get the DisplayName. Or you can add the DiaplayerName to the store item’s CustomData. Usually, it is recommended to locally cache catalog items for future reference. With code below you can get item’s ItemId, DiaplayName and prices, then you can use it to implement UI in the game.

public Dictionary<string, CatalogItem> Map = new Dictionary<string, CatalogItem>();

void Start()
{
    PlayFabClientAPI.LoginWithCustomID(new LoginWithCustomIDRequest
    {
        CustomId = "Gosen"
    },
    result => {
        GetCatalogItems();
    },
    error => { 
        Debug.Log(error.GenerateErrorReport());
    });
}

public void GetCatalogItems()
{
    PlayFabClientAPI.GetCatalogItems(new GetCatalogItemsRequest
    {
        CatalogVersion = "Main"
    },
    result => {
        foreach (CatalogItem item in result.Catalog)
        {
            Map.Add(item.ItemId, item);
        }
        GetStoreItems();
    },
    error => {
        Debug.Log(error.GenerateErrorReport());
    });
}

public void GetStoreItems()
{
    PlayFabClientAPI.GetStoreItems(new GetStoreItemsRequest
    {
        StoreId = "TestStore",

    },
    result => {
        foreach (var item in result.Store)
        {
            Debug.Log("ItemId:" + item.ItemId);
            Debug.Log("VirtualCurrencyPrices:" + item.VirtualCurrencyPrices["GC"]);
            Debug.Log("DisplayName:" + Map[item.ItemId].DisplayName);
        }
    },
    error => {
        Debug.Log(error.GenerateErrorReport());
    });
}
Comment
daksshbhambre
Hans Weber

People who like this

2 Show 1 · Share
10 |1200 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image daksshbhambre · Jun 06 at 02:19 PM 0
Share

Thank you so much!

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Navigation

Spaces
  • General Discussion
  • API and SDK Questions
  • Feature Requests
  • PlayStream
  • Bugs
  • Add-on Marketplace
  • LiveOps
  • Follow this Question

    Answers Answers and Comments

    2 People are following this question.

    avatar image avatar image

    Related Questions

    IAP Guide Parity 1 Answer

    Start multiplayer server from cloud script 3 Answers

    How would I handle a virtual currency online and offline?,Some questions about integration with PlayFab. 1 Answer

    iOS Reciept Validation Failed - Request Timeout 16 Answers

    iOS sandbox receipt validation is failing. 1 Answer

    PlayFab

    • Multiplayer
    • LiveOps
    • Data & Analytics
    • Runs on PlayFab
    • Pricing

    Solutions

    • For Any Role

      • Engineer
      • Designer
      • Executive
      • Marketer
    • For Any Stage

      • Build
      • Improve
      • Grow
    • For Any Size

      • Solo
      • Indie
      • AAA

    Engineers

    • Documentation
    • Quickstarts
    • API Reference
    • SDKs
    • Usage Limits

    Resources

    • Forums
    • Contact us
    • Blog
    • Service Health
    • Terms of Service
    • Attribution

    Follow us

    • Facebook
    • Twitter
    • LinkedIn
    • YouTube
    • Sitemap
    • Contact Microsoft
    • Privacy & cookies
    • Terms of use
    • Trademarks
    • Safety & eco
    • About our ads
    • © Microsoft 2020
    • Anonymous
    • Sign in
    • Create
    • Ask a question
    • Create an article
    • Post an idea
    • Spaces
    • PlayStream
    • Feature Requests
    • Add-on Marketplace
    • Bugs
    • API and SDK Questions
    • General Discussion
    • LiveOps
    • Explore
    • Topics
    • Questions
    • Articles
    • Ideas
    • Users
    • Badges