This is an old revision of the document!


InventoryQueryRq (Request)

The InventoryQueryRq request allows users to quickly retrieve stock quantity information from a product or option, without retrieving all of the other information about the product (for simplifying inventory checks). Only Stock Qty information for the product or option will be returned. It can be used to retrieve the quantity in stock for all of the products and options in the ecommerce website, or a single product, or a group of products based on the SKU conditions (Filters) you submit.

Retrieving Inventory for All Products

Although Fortune3 recommends filtering your requests in order to save bandwidth and response lengths, you can retrieve the stock information for all of the products on your ecommerce shopping cart. Proceed as follows:

Sample Code:

<sendRequestXML>
<authenticate>
<APIUsername>TWmY6WBft</APIUsername>
<APIPassword>SKW8ssAmDu6xTGDl</APIPassword>
</authenticate>
<InventoryQueryRq RequestID="1" />
</sendRequestXML>

Retrieving Inventory for Certain Products (Using Filters)

You can use Filters to limit which products you get in the response based on the SKU, and therefore highly optimize the response by shortening it to only include your desired products. Using the <Filters> node, you can specify as many sku filters as you like that must be matched in order for the Product to be returned in the response. Since you can specify multiple filters within the same request, and each filter can have different settings, you must also specify individual <Filter> nodes for each filter you want to add to your request. Proceed as Follows:

Sample Code (retrieving stock for product SKU “ABC1”):

<sendRequestXML>
<authenticate>
<APIUsername>TWmY6WBft</APIUsername>
<APIPassword>SKW8ssAmDu6xTGDl</APIPassword>
</authenticate>
<InventoryQueryRq RequestID="1">
  <Filters>
    <Filter>
      <SKU>ABC1</SKU>
    </Filter>
  </Filters>
</InventoryQueryRq>
</sendRequestXML>

Available Filters for InventoryQueryRq

Tag Name Sub-Tag Of Description Field Type Can Repeat
Filters InventoryQueryRq The Filters Activation Node Node False
Filter Filters The Current Filter Node Node True
SKU Filter Matches the Product's or Options 'SKU String True

Using Multiple Filters

You can use multiple filters within a single request by either adding the multiple filters to the same <Filter> node, or by adding separate <Filter> nodes for each filter. By using the same <Filter> node to list multiple SKU filters, you cannot add filtering options and you are therefore limited to the default filtering settings, which is to do an “exact” match of the SKU, and to separate each SKU filter with an “or”, so that each filter will produce a result independent of the other filters:

Sample Code (SKU matches “ABC1” or SKU matches “XYZ2”):

<sendRequestXML>
<authenticate>
<APIUsername>TWmY6WBft</APIUsername>
<APIPassword>SKW8ssAmDu6xTGDl</APIPassword>
</authenticate>
<InventoryQueryRq RequestID="1">
  <Filters>
    <Filter>
      <SKU>ABC1</SKU>
      <SKU>XYZ2</SKU>
    </Filter>
  </Filters>
</InventoryQueryRq>
</sendRequestXML>

Filtering Options

However, if you use multiple <Filter> nodes for each filter, you can specify the options for each SKU Filter using Filtering Options.

There are 2 XML tags that you can use on each filter to specify the options for that filter, <FilterMatch> and <FilterStyle>.

The 'FilterMatch' tag allows you to specify if you would like to do an “exact” match of the SKU filter (the default), or a “contains” match of the SKU filter, making the SKU match if the value you send partially matches the SKU in the databse (where SKU contains “ABC”).

The 'FilterStyle' tag is only used if you are using more than one <Filter> node and should only be used for the 2nd filter and on (not for the first). It allows you to specify if the current SKU filter you are sending should be matched with an 'or' parameter when following the previous SKU filter (the default), or an 'and' parameter. Using 'and' will make the current filter match in addition to the previous filter (which is why the first filter should not have it), whereas using 'or' (or omitting the 'FilterStyle' since this is the default value) will make the current SKU filter match, whether or not the previous SKU filter matched.

Tag Name Sub-Tag Of Description Field Type Allowed Values Can Repeat
FilterStyle Filter Specifies if the current filter is
independent from the previous filter
String “or”
“and”
False
FilterMatch Filter Specifies if the current filter must
be an exact match or a “like” match
String “exact”
“contains”
False

Sample Code (SKU contains “ABC” or SKU contains “XYZ”):

<sendRequestXML>
<authenticate>
<APIUsername>TWmY6WBft</APIUsername>
<APIPassword>SKW8ssAmDu6xTGDl</APIPassword>
</authenticate>
<InventoryQueryRq RequestID="1">
  <Filters>
    <Filter>
      <SKU>ABC</SKU>
      <FilterMatch>contains</FilterMatch>
    </Filter>
    <Filter>
      <SKU>XYZ</SKU>
      <FilterMatch>contains</FilterMatch>
      <FilterStyle>or</FilterStyle> (optional)
    </Filter>
  </Filters>
</InventoryQueryRq>
</sendRequestXML>

Using these guidelines, you can fully filter out the InventoryQueryRq to only provide you with the products that you need.

Next: Reading the Response (InventoryQueryRs)

Print/export