We have been working on an inventory system for one of our clients for a long time and recently, what we needed was to retrieve inventory item information by UPC code or ISBN or EAN. so the end customer does not need to fill a full form with all the details.
We implemented a feature where customers can just enter or scan UPC/ISBN/EAN code on the mobile app and we retrieve all the information of the product and auto-fill it with an image of the product as well.
So we started using UPCItemDB which has a very nice database of items. You can call their API and retrieve information about the product by sending UPC code. It has a free plan that you can use for trial purposes.
But there was no proper PHP or Laravel package for that, so we decided to make our own and publish it to Github.
It’s called laravel-upcitemdb and here is the link for it: https://github.com/InfyOmLabs/laravel-upcitemdb
Here are the installation steps and how to use this package.
Installation
Install the package by the following command,
composer require infyomlabs/laravel-upcitemdb
Publish the config file
Run the following command to publish config file,
php artisan vendor:publish --provider="InfyOm\UPCItemDB\UPCItemDBServiceProvider"
Add Facade
Add the Facade to your config/app.php into aliases section,
'UPCItemDB' => \InfyOm\UPCItemDB\UPCItemDB::class,
Usage
Lookup
For UPC Lookup, use the lookup method by calling,
\UPCItemDB::lookup('4002293401102');
Search
For Search API, you can use the search method,
\UPCItemDB::search('iphone 6');
\UPCItemDB::search('iphone 6', ['brand' => 'apple']);