How to check if Online Store sales channel is active for a product

Hi,

In our app we have a table showing a list of products associated with our app. We want to create a badge that shows if the Online Sales Channel is active for each product in the table.

We were using the publications query to check if the publication Catalog.title matched “Online Store”, but then we realised that if a merchant has changed their language, the publication name returns the phrase “Online Store” translated, resulting in errors.

Is there a better way to approach this? I can’t seem to find any queries for something like Catalog.type where we can access a consistent value to identify the Online Sales Channel that doesn’t change if the merchant changes their language.

Any advice would be much apprecaited :folded_hands:

1 Like

Hey Adam,

Could you use the publication ID for the Online Store instead? You’d first query to fetch all available publications and identify the ID for the Online Sales Channel. Once you have the id of the Online Sales Channel, you can then query the publications field of a product to check if it is published to that channel.

1 Like

Hey Liam,

Thank you very much for taking the time to respond, and for your help and suggestions :folded_hands:

Your suggestion is excellent, thank you, and I will absolutely test this.

But how do I actually identify the ID of the Online Sales channel? It seems that the list of publications are being returned translated for the merchant / user that is signed in (depending on the language that they have set in their Shopify account).

Thanks again Liam,
Adam

1 Like

Hi again Adam,

I do see what you mean - there may need to be a step where you verify which publication ID that is returned, is the Online Store one, when you query all publications. Is this for a public or custom app?

Hey Liam,

Thanks so much. This is for a public app.

The temporary solution that we have come up with is we are checking if the first publication is active, which 99% of the time seems to be the online store. But of course this is not a very robust solution.

I’m hoping that there is a better way of querying if the Online Sales Channel is active than needing to hard code the phrase “Online Store” in all available languages..

Thank you for all your help and support Liam, it is much appreciated :slight_smile:

1 Like

Hi again Liam,

I just wanted to follow up on this. Is there a standardized way for us to query and set sales channels on products that doesn’t get translated? Or can this be added as a feature request please? For example, it would be extremely helpful if there was a publication type that we could access, that isn’t affected by translations, such as:

  • online_store
  • point_of_sale
  • shop

And so on.

Thank you so much,
Adam

1 Like