question

ryo1102 avatar image
ryo1102 asked

return Bundles Catalog is Durable or Consumable?

Hi, I'm a beginner to using Playfab for my games. I have a store that buys things with real money. Initially, I used GetCatalogItems to get the items. Then I want to know if my items are "Durable" or "Consumable" to assign to ProductType. I use the Unity Purchase. For example: foreach (var item in directory) { builder.AddProduct (item.ItemId, ProductType.Consumable); } Please support me. thanks

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

·
Rick Chen avatar image
Rick Chen answered

Make sure the PlayFab SDK is set up in Unity. An example of separating “Durable item” and “Consumable item” in Unity could be:

    List<CatalogItem> consumable_items;
    List<CatalogItem> durable_items;
    public void GetCatalogItems()
    {
        consumable_items = new List<CatalogItem>();
        durable_items = new List<CatalogItem>();


        PlayFabClientAPI.GetCatalogItems(new GetCatalogItemsRequest {
            CatalogVersion = "Your Catalog Version" // replace your catalog version here
        },
        (GetCatalogItemsResult result) => {
        
            foreach (CatalogItem item in result.Catalog)
            {
                if (
                item.Consumable.UsageCount>0 //whether it is consumable by count
                || item.Consumable.UsagePeriod>0) //whether it is consumable by time
                {
                    consumable_items.Add(item);
                }
                else
                {
                    durable_items.Add(item);
                }
            }
        
        },
        null //your error callback here
        );


    }


Make sure that the SDK is imported, and the CatalogVersion is replaced with your own catalog version.

1 comment
10 |1200

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

Ryo avatar image Ryo commented ·

Thank you very much

0 Likes 0 ·

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.