### Install laravel-shopify with Composer Source: https://github.com/jeffersongoncalves/laravel-shopify/blob/main/README.md Installs the laravel-shopify package via Composer. ```bash composer require jeffersongoncalves/laravel-shopify ``` -------------------------------- ### Get shop details Source: https://github.com/jeffersongoncalves/laravel-shopify/blob/main/README.md Retrieve the current shop information. ```php Shopify::shop()->get(); ``` -------------------------------- ### Product CRUD and listing operations Source: https://github.com/jeffersongoncalves/laravel-shopify/blob/main/README.md Perform product operations: list with filters, get by ID, count, list variants, create, update, and delete. ```php Shopify::products()->list(limit: 50, filters: ['vendor' => 'Acme', 'status' => 'active']); Shopify::products()->get(123); Shopify::products()->count(); Shopify::products()->variants(123); Shopify::products()->create([ 'title' => 'Product Name', 'body_html' => '
Description
', 'vendor' => 'Brand', 'product_type' => 'Category', 'variants' => [ ['price' => '99.00', 'sku' => 'SKU-001'], ], ]); Shopify::products()->update(123, ['title' => 'Renamed']); Shopify::products()->delete(123); ``` -------------------------------- ### Order management operations Source: https://github.com/jeffersongoncalves/laravel-shopify/blob/main/README.md Manage orders: list with status 'any' (defaults to open orders), get, fulfillments, cancel, close, and open. ```php // Shopify defaults to open orders only; this defaults to `any` Shopify::orders()->list(limit: 50, status: 'any'); Shopify::orders()->get(42); Shopify::orders()->fulfillments(42); Shopify::orders()->cancel(42, ['reason' => 'customer']); Shopify::orders()->close(42); Shopify::orders()->open(42); ``` -------------------------------- ### Customer management operations Source: https://github.com/jeffersongoncalves/laravel-shopify/blob/main/README.md Manage customers: list, get, search by email, list orders, create, update, and delete. ```php Shopify::customers()->list(limit: 50); Shopify::customers()->get(7); Shopify::customers()->search('email:ada@example.com'); Shopify::customers()->orders(7); Shopify::customers()->create(['email' => 'ada@example.com', 'first_name' => 'Ada']); Shopify::customers()->update(7, ['last_name' => 'Lovelace']); Shopify::customers()->delete(7); ``` -------------------------------- ### Generic REST endpoint calls Source: https://github.com/jeffersongoncalves/laravel-shopify/blob/main/README.md Call any Shopify REST endpoint using the generic get and post methods. ```php Shopify::get('/inventory_levels', ['location_ids' => '123']); Shopify::post('/price_rules', ['price_rule' => [/* ... */]]); ``` -------------------------------- ### Import Shopify facade and exception Source: https://github.com/jeffersongoncalves/laravel-shopify/blob/main/README.md Import the Shopify facade and the ShopifyException class before using the package. ```php use JeffersonGoncalves\Shopify\Facades\Shopify; use JeffersonGoncalves\Shopify\Exceptions\ShopifyException; ``` -------------------------------- ### Shopify Config Options Source: https://github.com/jeffersongoncalves/laravel-shopify/blob/main/README.md Default configuration options. base_url is built from the shop domain and API version when left unset; set it only to point the client at something else, such as a local mock server. ```php // config/shopify.php return [ 'shop_domain' => env('SHOPIFY_SHOP_DOMAIN'), 'access_token' => env('SHOPIFY_ACCESS_TOKEN'), 'api_version' => env('SHOPIFY_API_VERSION', '2024-01'), 'base_url' => env('SHOPIFY_BASE_URL'), 'timeout' => (int) env('SHOPIFY_TIMEOUT', 30), ]; ``` -------------------------------- ### Publish Shopify Config File Source: https://github.com/jeffersongoncalves/laravel-shopify/blob/main/README.md Optionally publishes the package's config file to the application's config directory. ```bash php artisan vendor:publish --tag="shopify-config" ``` -------------------------------- ### Configure Shopify Environment Variables Source: https://github.com/jeffersongoncalves/laravel-shopify/blob/main/README.md Environment variables required for the package. The access token can be created as a custom app in your store under Settings → Apps and sales channels → Develop apps, granting the needed Admin API scopes. A token from a public app's OAuth flow works the same way. ```env SHOPIFY_SHOP_DOMAIN=my-store.myshopify.com SHOPIFY_ACCESS_TOKEN=shpat_xxxxxxxxxxxxxxxxxxxxxxxx SHOPIFY_API_VERSION=2024-01 ``` -------------------------------- ### GraphQL query with variables Source: https://github.com/jeffersongoncalves/laravel-shopify/blob/main/README.md Execute a GraphQL query using a heredoc string and variables. The result is accessible via the returned data array. ```php $data = Shopify::graphql(<<<'GQL' query ($first: Int!) { products(first: $first) { edges { node { id title totalInventory } } } } GQL, ['first' => 10]); $data['products']['edges']; ``` -------------------------------- ### Webhook management operations Source: https://github.com/jeffersongoncalves/laravel-shopify/blob/main/README.md Create, list, and delete webhooks. Common topics include orders/create, orders/paid, orders/fulfilled, customers/create, products/update, and checkouts/create. ```php Shopify::webhooks()->create('orders/create', 'https://example.com/hooks/orders'); Shopify::webhooks()->list(); Shopify::webhooks()->delete(1); ``` -------------------------------- ### Handle Shopify API errors Source: https://github.com/jeffersongoncalves/laravel-shopify/blob/main/README.md Catch ShopifyException to handle API errors. The exception provides getMessage() and statusCode (0 for config errors). ```php try { $products = Shopify::products()->list(); } catch (ShopifyException $e) { // $e->getMessage() — the API's error message, or the raw response body // $e->statusCode — the HTTP status returned by Shopify (0 for config errors) } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.