> ## Documentation Index
> Fetch the complete documentation index at: https://devdocs.xbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# XStoreQueryConsumableBalanceRemainingAsync

> XStoreQueryConsumableBalanceRemainingAsync

# XStoreQueryConsumableBalanceRemainingAsync

Get the consumable balance remaining for the specified product ID.

## Syntax

```cpp theme={null}
HRESULT XStoreQueryConsumableBalanceRemainingAsync(  
         const XStoreContextHandle storeContextHandle,  
         const char* storeProductId,  
         XAsyncBlock* async  
)  
```

### Parameters

*storeContextHandle*   \_In\_\
Type: XStoreContextHandle

The store context handle for the user returned by [XStoreCreateContext](/reference/system/xstore/functions/xstorecreatecontext).

*storeProductId*   \_In\_z\_\
Type: char\*

The ID of the consumable to retrieve the balance for.

*async*   \_Inout\_\
Type: [XAsyncBlock\*](/reference/system/xasync/structs/xasyncblock)

An [XAsyncBlock](/reference/system/xasync/structs/xasyncblock) defining the asynchronous work being done. The [XAsyncBlock](/reference/system/xasync/structs/xasyncblock) can be used to poll for the call's status and retrieve call results. See [XAsyncBlock](/reference/system/xasync/structs/xasyncblock) for more information.

### Return value

Type: HRESULT

HRESULT success or error code.

## Remarks

To retrieve the remaining consumable balance as well as the execution result of this function call [XStoreQueryConsumableBalanceRemainingResult](/reference/system/xstore/functions/xstorequeryconsumablebalanceremainingresult) after calling this function. [XStoreQueryConsumableBalanceRemainingResult](/reference/system/xstore/functions/xstorequeryconsumablebalanceremainingresult) should be executed in the callback function for **XStoreQueryConsumableBalanceRemainingAsync**. The following code snippet shows an example of retrieving the consumable balance remaining for a specified product ID.

```cpp theme={null}
void CALLBACK QueryConsumableBalanceRemainingCallback(XAsyncBlock* asyncBlock)
{
    XStoreConsumableResult result{};
    HRESULT hr = XStoreQueryConsumableBalanceRemainingResult(
        asyncBlock,
        &result);

    if (FAILED(hr))
    {
        printf("Failed retrieve the consumable balance remaining: 0x%x\r\n", hr);
        return;
    }

    printf("quantity: %d\r\n", result.quantity);
}

void QueryConsumableBalanceRemaining(XStoreContextHandle storeContextHandle, XTaskQueueHandle taskQueueHandle, const char* storeId)
{
    auto asyncBlock = std::make_unique<XAsyncBlock>();
    ZeroMemory(asyncBlock.get(), sizeof(*asyncBlock));
    asyncBlock->queue = taskQueueHandle;
    asyncBlock->callback = QueryConsumableBalanceRemainingCallback;

    HRESULT hr = XStoreQueryConsumableBalanceRemainingAsync(
        storeContextHandle,
        storeId,
        asyncBlock.get());

    if (FAILED(hr))
    {
        printf("Failed to get consumable balance remaining: 0x%x\r\n", hr);
        return;
    }
}

```

## Requirements

**Header:** XStore.h (included in XGameRuntime.h)

**Library:** xgameruntime.lib

**Supported platforms:** Windows, XBOX One family consoles and XBOX Series consoles

## Conceptual documentation

* [Basic store operations](/publishing/xstore-commerce/xstore-basic-operations)

## See also

[XStore](/reference/system/xstore/xstore_members)\
[XStoreQueryConsumableBalanceRemainingResult](/reference/system/xstore/functions/xstorequeryconsumablebalanceremainingresult)\
[XStoreCreateContext](/reference/system/xstore/functions/xstorecreatecontext)


## Related topics

- [XStoreQueryConsumableBalanceRemainingResult](/reference/system/xstore/functions/xstorequeryconsumablebalanceremainingresult.md)
- [XStoreConsumableResult](/reference/system/xstore/structs/xstoreconsumableresult.md)
- [Basic store operations](/publishing/xstore-commerce/xstore-basic-operations.md)
- [XStore](/reference/system/xstore/xstore_members.md)
- [Unity C# API wrappers for the GDK](/build/gdk-and-engines/unity/unity-api-wrappers.md)
