question

romagoldun avatar image
romagoldun asked

How to get items quantity in bundle?

Quantity is always 0, although I know for sure that there are more items in the bundle. And if you don’t check for quantity, the cards will spawn, but if you do, then they won’t. So DataProvider works correctly because it returns list of bundles. But ItemReferences return 0 Amount

 private List<GamePassWindowData.GamePassReward> SetCards(CatalogItem item)
         {
             var cards = DataProvider.GetItemsFromBundle(item.Id)
                 .SelectMany(bundleItem =>
                 {
                     int level = GetLevelFromItem(bundleItem);
                     int quantity = bundleItem.ItemReferences?.Sum(itemRef => itemRef.Amount) ?? 0;
        
                     return Enumerable.Repeat(new GamePassWindowData.GamePassReward
                     {
                         Level = level,
                         Amount = quantity
                     }, quantity);
                 })
                 .ToList();
        
             return cards;
         }
In-Game Economy
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

·
Neils Shi avatar image
Neils Shi answered

Could you tell us how you retrieve the number of items in the bundle? According to your code, it looks like you are using Economy v2, then you can call the API GetItem or SearchItems to retrieve the number of items in the bundle. The information about item quantities is contained in "ItemReferences", for example:

 "ItemReferences": [
                     {
                         "Id": "f385520d-c727-4b9e-8545- xxxxxxxxxxxx",
                         "Amount": 3
                     },
                     {
                         "Id": "a8cc3c8c-6590-411f-8876- xxxxxxxxxxxx",
                         "Amount": 5
                     }
                 ]
2 comments
10 |1200

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

romagoldun avatar image romagoldun commented ·

I did as you said and quantity always == 0 (itemReferences == null)

     public void AddCard(GamePassWindowData.GamePassReward cardData)
     {
         GameObject cardGameObject = Instantiate(_gamePassCard.gameObject, _cardsContainer);
         GamePassCard gamePassCard = cardGameObject.GetComponent<GamePassCard>();
    
         gamePassCard.InjectPlayerData(Presenter.PlayerData);
    
         CatalogItem bundleItem = DataProvider.GetItemsFromBundle(CatalogItem.Id).First(x => GetLevelFromItem(x) == cardData.Level);
    
         int quantity = bundleItem.ItemReferences?.FirstOrDefault()?.Amount ?? 0;
    
         gamePassCard.InitializeWithReward(bundleItem, cardData, quantity, Presenter.Wallet, Presenter);
    
         _gamePassCards.Add(gamePassCard);
     }
0 Likes 0 ·
Neils Shi avatar image Neils Shi romagoldun commented ·

Could you provide us with the code that you use our API to retrieve the quantity of items in the bundle so we can do some research?

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.