Use the Shopify API in Laravel With the Laravel Shopify Package

Packages

October 14th, 2021

online-shopping-mobile-featured.png

Laravel Shopify is a package to communicate with the Shopify API from Laravel applications. Here are a few examples from the project's documentation overview:

1$shopify = \Signifly\Shopify\Factory::fromConfig();
2 
3// Paginate products
4$cursor = $shopify->paginateProducts(); // returns a Cursor
5 
6// Get products count
7$count = $shopify->getProductsCount(); // returns an integer
8 
9// Get products
10$products = $shopify->getProducts(); // returns a Collection of ProductResource
11 
12// Create a product
13$product = $shopify->createProduct([
14 'title' => 'Adidas Shoe, Pink',
15]); // returns a ProductResource
16 
17// Get a specific product
18$product = $shopify->getProduct($productId); // returns a ProductResource
19 
20// Update a product
21$product = $shopify->updateProduct($productId, [
22 'title' => 'Adidas Shoe, Rose',
23]); // returns a ProductResource
24 
25// Deleting a product
26$shopify->deleteProduct($productId);

This package covers quite a few endpoints from the API and even provides the ability to make custom requests to the Shopify API, taking care of credentials, etc.:

1$shopify->put('products/{product_id}.json', $payload);

Custom requests return an Illuminate client Response instance, so you can use all the available methods on the response instance you can in any HTTP request using Laravel's client.

The package has API methods for the following high-level Shopify features:

  • Access
  • Analytics
  • Billing
  • Customers
  • Discounts
  • Events
  • Inventory
  • Marketing Events
  • Metafields
  • Online store
  • Orders
  • Plus
  • Products
  • Sales Channel
  • Shipping and Fulfillment
  • Shopify Payments
  • Store properties
  • Tender Transactions

The documentation has a complete list of all the methods with links to official Shopify API parameters and documentation.

You can learn more about this package, get full installation instructions, and view the source code on GitHub.

Filed in:

Paul Redmond

Full stack web developer. Author of Lumen Programming Guide and Docker for PHP Developers.