Retrieve category from order item

Hello! I’m stuck on part of the v1 to v2 migration for the payments api that involves getting an order line item’s category name. Previously it was available from the payments api here: itemizations.item_detail.category_name. The migration guide says:

You can use the `OrderLineItem.catalog_object_id to retrieve the catalog information.

So I am using the order api to retrieve the order and the catalog api to retrieve the catalog item. However when I use the catalog_object_id to retrieve the catalog object from the catalog api, I get an item variation in return, not a category. Am I mixing something up here? Any guidance would be much appreciated. Thank you!

:wave: With the Catalog API you can set include_related_object to true to get the category the items associated with. :slightly_smiling_face:

Ah, that returns a category id. So to be clear, in order to to get the category name from an order I need to make two separate api calls

  • retrieve the item variation from the catalog api with the catalog_object_id
  • retrieve the category from the catalog api with the category_id

Am I missing a simpler way of doing this or is this accurate?

You got it! That’s it! :slightly_smiling_face:

1 Like