FROM CACHE - en_header

Storefront API: Get product details from barcode

ahmar2
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.
Replies 21 (21)
ahmar2
New Member
3 0 0
Alex
Shopify Staff
Shopify Staff
1561 81 324

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.

Alex | Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit the Shopify Help Center or the Shopify Blog

ahmar2
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
Alex
Shopify Staff
Shopify Staff
1561 81 324

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.

Alex | Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit the Shopify Help Center or the Shopify Blog

DOB
Excursionist
13 0 9

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!

blueberry-pay
Excursionist
14 0 11

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

Standish
New Member
2 0 17

Hi,

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

We want to do the same.

Thank you,

Patrick

Greg_Kujawa
Shopify Partner
1023 84 266

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?

DOB
Excursionist
13 0 9

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.

Greg_Kujawa
Shopify Partner
1023 84 266

Agreed. The different API types should all match up in terms of what's exposed, what's accessible, etc. Otherwise it's a guessing game to a degree. While I found the REST API to be better documented with examples and whatnot, I moved over to the GraphQL API when I found gaps that only it could fill. Although it's not nearly as well documented with working examples and less natural feeling. But then again I control my own API integrations so I had to luxury to move between the two. If you are dependent upon third party integrators then that's amiss!

Rahul-LMP
Excursionist
41 0 5

ahmar i need an app like this too can we connect +1 502 303 4518 wats app me urgently please

Rahul-LMP
Excursionist
41 0 5

hi alex need urgent help 

 

Need Urgent Help from people who do FBA and Retail Using Shopify
 
so our products have xxx barcode printed on our products, but in shopify we have yyy as a barcode , so i want to ensure when on pos we scan xxx the yyy product pops up, so storing 2 barcodes on this product is the only solution I can think of but Shopify doesn't let you do that. the reason is we have amazon fnsku printed on our products and that is alphanumeric and for gmc purposes, we can not put alphanumeric barcodes in Shopify( gmc throws an error ) SO Shopify has a numeric barcode stored , so now on Shopify pos we will be scanning fnsku but it will say product not found coz the product has a numeric barcode in Shopify pos . so using this bridge api is there a way to add or make an app that will search in a custom field also for another field , currently i think when you scan shopify only searches barcode field so can a app be made where in it seraches barcode or another custom field or tag ?
Rahul-LMP
Excursionist
41 0 5

greg can we connect i need custom app built 

Greg_Kujawa
Shopify Partner
1023 84 266

@Rahul-LMP  I am not an independent developer per-se, as I develop apps for the retail company I work for. So I really can't fully dive into an outside project. Testing out the barcode scenario that was mentioned recently in this thread, I was able to store alphanumeric values using the Shopify web UI. See screen shot below. 

Untitled.png 

 

My advice would be to be consistent with how merchandise is tagged. It isn't reasonable to either have two physical tags on each item, as likewise it isn't reasonable to store two different barcode values in the Shopify platform. Whatever tags are used with the items should have those values stored in the appropriate Shopify product field. Once that's taken place then barcode scanning them in Shopify POS should pull the item up as expected. 

Using the API you can either modify a product's barcode field value, or query products to find that particular barcode. Not to mention a variety of other operations.  

Rahul-LMP
Excursionist
41 0 5

my probelm is not that we cant store alpha numeric barcode its , that i want to store 2 barcodes for single variant which are then serachable on shopify pos scanner 

Greg_Kujawa
Shopify Partner
1023 84 266

So if you want to essentially store an extra barcode data field in each variant, you can utilize the Metafield to plug this in. Described here --> https://shopify.dev/docs/admin-api/rest/reference/metafield. This is a data element that will be accessible via the API but not through the web admin (if I'm not mistaken). But you can use this to define the alternate Amazon barcode for each variant, a URL to the Amazon item, etc. 

As for the "Shopify POS scanner" you have cross-posted around and about the past day, I assume you mean that you want the Shopify user to be able to scan either barcode and the correct item will come up in Shopify POS, correct? Natively I'm not sure this is doable. You can loose search for items in Shopify POS and of course you can barcode scan to pull the defined barcode. Shopify POS is customizable to a degree via either the App Bridge or the Embedded App SDK. But usually this is for things like Edit Cart, not changing the logic and behavior of the item search box.

The fact there aren't multiple folks on here piping up and providing feedback could mean that this scenario is pretty unlikely or clumsy at best. Standard retail business practices don't lend themselves to being able to pull up one item by scanning more than one tag that's hanging off of it. Usually it's a single unique identifier. You would need to think outside the box...rolling up your own POS app where you control everything (a lot of time and effort); maintaining a separate reference mapping resource that cross-references the Shopify barcode to determine the Amazon barcode (a little more viable); modifying your business practices to better align with what's practical and possible (what I would do). 

DOB
Excursionist
13 0 9

Just to respond to this since you put the time into your comment (although not directed at me) - we actually found a workaround for this using Admin API and metafields based on your suggestion. By creating custom metafields we can pass along additional information that can then be pulled using the metafields portion of the Admin API. Unlike the other poster, our limitations were due to having multiple logistics providers whose ERPs were pulling different codes to fulfill orders (SKU, GTIN and UPC). In an ideal world they would all get on the same page and just use the SKU or GTIN, but for now we can still use the Admin API while passing the different values they need.

Rahul-LMP
Excursionist
41 0 5

Can we connect on a call or email my email is rahul@buildmyplace.com or call me at 502 303 4518 i am from louisville ky so +1 code incase you are outside the us and same

no on wats app

policenauts
Shopify Partner
194 9 57

@DOB @Greg_Kujawa his challenge isn't storing metafields, it's actually querying by a custom metafield value which to my knowledge isn't possible: https://community.shopify.com/c/Shopify-Discussion/Query-all-products-with-a-given-metafield-value/t...

To achieve what he wants, one would have to keep an entire synced database mirror of the store's products with the metafield as the unique key by which you can query. If a better way / workaround exists, please do share here (and help him!) as I scoped this and it was more complicated than I wanted to take on at the time.