Storefront API: Get product details from barcode

Highlighted
New Member
3 0 0

Hi,

I am developing a mobile APP in Angular Js using storefront API. I want to create a simple search field where customer can enter the barcode of the product and it returns product details like product price description etc.

 

The physical store has thousands of products and this simple mobile app will let customers to get product price without going to POS counter.

 

I am aware of store front API getProductByID function that is availble in angular example on github. But what will be the best way (least resource expensive way) to get product details by Product barcode. In the store itself the Barcodes are saved in

Barcode (ISBN, UPC, GTIN, etc.) field.
 
Can anyone please point me to the correct direction.
 
Thank you.
A.
0 Likes
Highlighted
New Member
3 0 0

Anyone?

0 Likes
Highlighted
Shopify Staff
Shopify Staff
1555 81 279

While you cannot query on the barcode over the storefront API, you can use the Admin GraphQL API's query argument to search on bar code. https://help.shopify.com/en/api/graphql-admin-api/reference/queryroot

 

I'm not sure why you can't do this via the storefront API seeing how that property of the product is surfaced there, so I'll talk to some teams about perhaps implementing that improvement if it makes sense.

 

Cheers.

0 Likes
Highlighted
New Member
3 0 0
Hi Alex
The problem is querying the shopify data publically through an external app. Doing this via admin api gives CORS error as the origin of the request isn't similar to the shopify. Also it is insecure. So can you point me in the right direction regarding external apps.
Thanks
0 Likes
Shopify Staff
Shopify Staff
1555 81 279

While using the admin API directly via the client would be insecure, you could delegate to your backend to make the requests with client-side javascript. The response from your backend can be the forwarded response from the admin API. Would that work better for you?

 

Cheers.

0 Likes
Highlighted
Tourist
5 0 2

I'm not sure why you can't do this via the storefront API seeing how that property of the product is surfaced there, so I'll talk to some teams about perhaps implementing that improvement if it makes sense.

Hi @Alex any update on this by chance? It seems VERY strange to me that querying orders.json doesn't include the product's barcode/UPC/ISBN etc - many warehousing/shipping/logistics services absolutely require this to be included with orders, not just the SKU. Many thanks in advance!

2 Likes
Highlighted
Excursionist
11 0 6

Is there any plan to add the barcode attribute to the record? I think it belongs together and would make the work a bit easier

1 Like
Highlighted
New Member
2 0 4

Hi,

did you find a solution or got an answer for that?

We want to do the same.

Thank you,

Patrick

0 Likes
Highlighted
Shopify Partner
355 24 76

The solution appears to be querying products for the barcode using the GraphQL API. Example below, pulling the first 5 variants for the first 5 products that have a barcode value of 123456789012.

{
  products(first: 5, query: "barcode:123456789012") {
    edges {
      node {
        id
        title
        variants(first: 5) {
          edges{
            node
            {
              id
              title
              price
            }
          }
        }
      }
    }
  }
}

While this query doesn't appear to exist in the REST API, the fact that it does exist in the GraphQL API should be a workaround, correct?

0 Likes
Highlighted
Tourist
5 0 2

I believe you are correct from my understanding of reading all the documentation (APIs are something I'm only mildly familiar with). The issue for us though is that one of our logistics suppliers is using REST and for the moment aren't able to switch to GraphQL. I know there are a few 3rd-party integrations that do the same, so I think it would make sense to include it in REST at some point.

0 Likes