question

Kim Strasser avatar image
Kim Strasser asked

How can I list all store items to the player?

I want to list all the items with their name, description and price when the player opens the shop in my game. In addition, I don't want that you can exceed the maximum quantity of an item. For example, it shouldn't be possible that a user has more than 3 Bamboo Swords in his inventory. If a user has 3 Bamboo Swords, then he can not make another Bamboo Sword purchase. But it should be possible to purchase another Bamboo Sword after you consumed one in the game.

I have 3 items in my primary catalog. In addition, I created a store with the same 3 items, 2 of them are on sale in this store(Id = "EventSale").

I created a foreach loop, but I don't know how to get the name and description of the items. I just get the ItemId, VirtualCurrencyPrices and RealCurrencyPrices. Is it not possible to get the name and a description of the item when I use GetStoreItemsAsync?

        private async Task GetVcStore()
        {
            var primaryCatalogName = "New Shop";
            var storeId = "EventSale";

            var result = await PlayFabClientAPI.GetStoreItemsAsync(new GetStoreItemsRequest()
            {
                CatalogVersion = primaryCatalogName,
                StoreId = storeId
            });

             foreach (var entry in result.Result.Store)
            {
                Console.WriteLine($"{entry.ItemId} {entry.VirtualCurrencyPrices} {entry.RealCurrencyPrices}");
            }

            if (result.Error != null)
            {
                Console.WriteLine(result.Error.GenerateErrorReport());
            }
            else
            {
                Console.WriteLine("Listed items successful!");
            }
        }

In my PlayFab account, you can see the 3 items. I want to get the display name and description of each item in my game. In this case, it would be "Bamboo Sword" and "Get the fantastic Bamboo Sword!".

pricing
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
jital avatar image
jital answered

Greetings,

In order to list the name and description of items use GetCatalogItem in conjunction with GetStoreItem

This forum post contains more information about this and information on how to reduce API calls when doing this.

One way to limit the amount of items a player can hold, is to check the player's inventory when they attempt to buy the item.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.