### Install package with Composer Source: https://github.com/jeffersongoncalves/laravel-woocommerce/blob/main/README.md Installs the package via Composer. Run this in your Laravel project root. ```bash composer require jeffersongoncalves/laravel-woocommerce ``` -------------------------------- ### Get reports and system status with Woocommerce facade Source: https://github.com/jeffersongoncalves/laravel-woocommerce/blob/main/README.md Retrieve sales and top sellers reports with a period filter, and get the system status. ```php Woocommerce::salesReport(['period' => 'week']); Woocommerce::topSellersReport(['period' => 'month']); Woocommerce::systemStatus(); ``` -------------------------------- ### Get an order with the Woocommerce facade Source: https://github.com/jeffersongoncalves/laravel-woocommerce/blob/main/resources/boost/skills/laravel-woocommerce-development/SKILL.md Shows the primary pattern for calling WooCommerce REST API methods from Laravel. The facade resolves the singleton and returns a Laravel HTTP Client Response. ```php use Jeffersongoncalves\Woocommerce\Facades\Woocommerce; $response = Woocommerce::getOrder(727); if ($response->successful()) { $order = $response->json(); } ``` -------------------------------- ### Run tests with composer test Source: https://github.com/jeffersongoncalves/laravel-woocommerce/blob/main/README.md Runs the test suite for the Laravel WooCommerce package. Use this command after installing dependencies to verify the package works as expected. ```bash composer test ``` -------------------------------- ### Manage products with Woocommerce facade Source: https://github.com/jeffersongoncalves/laravel-woocommerce/blob/main/README.md Use the Woocommerce facade to list, retrieve, create, update, and delete products. The deleteProduct method moves to trash by default; pass force: true to delete permanently. ```php use Jeffersongoncalves\Woocommerce\Facades\Woocommerce; Woocommerce::listProducts(['per_page' => 20, 'status' => 'publish', 'search' => 'shirt']); Woocommerce::getProduct(99); Woocommerce::createProduct([ 'name' => 'T-Shirt', 'type' => 'simple', 'regular_price' => '21.99', 'categories' => [['id' => 9]], ]); Woocommerce::updateProduct(99, ['regular_price' => '19.99']); Woocommerce::deleteProduct(99); // moves to trash Woocommerce::deleteProduct(99, force: true); // deletes permanently ``` -------------------------------- ### Manage product categories and tags with Woocommerce facade Source: https://github.com/jeffersongoncalves/laravel-woocommerce/blob/main/README.md Manage product categories and tags: list, retrieve, create, update, and delete for each resource. ```php Woocommerce::listProductCategories(); Woocommerce::getProductCategory(9); Woocommerce::createProductCategory(['name' => 'Hoodies', 'slug' => 'hoodies']); Woocommerce::updateProductCategory(9, ['description' => 'Warm stuff']); Woocommerce::deleteProductCategory(9); Woocommerce::listProductTags(); Woocommerce::getProductTag(4); Woocommerce::createProductTag(['name' => 'Summer']); Woocommerce::updateProductTag(4, ['slug' => 'summer']); Woocommerce::deleteProductTag(4); ``` -------------------------------- ### Manage taxes, payment gateways, and shipping with Woocommerce facade Source: https://github.com/jeffersongoncalves/laravel-woocommerce/blob/main/README.md Manage tax rates, payment gateways, and shipping zones: list, retrieve, create/update/delete for tax rates; list, retrieve, update for payment gateways; list shipping zones and their methods. ```php Woocommerce::listTaxRates(['class' => 'standard']); Woocommerce::getTaxRate(1); Woocommerce::createTaxRate(['country' => 'BR', 'rate' => '17.0000', 'name' => 'ICMS']); Woocommerce::updateTaxRate(1, ['rate' => '18.0000']); Woocommerce::deleteTaxRate(1); Woocommerce::listPaymentGateways(); Woocommerce::getPaymentGateway('bacs'); Woocommerce::updatePaymentGateway('bacs', ['enabled' => true]); Woocommerce::listShippingZones(); Woocommerce::getShippingZone(3); Woocommerce::listShippingZoneMethods(3); ``` -------------------------------- ### Manage orders with Woocommerce facade Source: https://github.com/jeffersongoncalves/laravel-woocommerce/blob/main/README.md Manage orders: list with filters, retrieve, create with billing and line items, update status, and delete. ```php Woocommerce::listOrders(['status' => 'processing', 'per_page' => 50, 'after' => '2026-01-01T00:00:00']); Woocommerce::getOrder(727); Woocommerce::createOrder([ 'payment_method' => 'bacs', 'billing' => ['first_name' => 'Jane', 'email' => 'jane@example.com'], 'line_items' => [['product_id' => 99, 'quantity' => 2]], ]); Woocommerce::updateOrder(727, ['status' => 'completed']); Woocommerce::deleteOrder(727); ``` -------------------------------- ### Manage webhooks with Woocommerce facade Source: https://github.com/jeffersongoncalves/laravel-woocommerce/blob/main/README.md Manage webhooks: list, retrieve, create with topic and delivery URL, update status, and delete. ```php Woocommerce::listWebhooks(); Woocommerce::getWebhook(2); Woocommerce::createWebhook('order.created', 'https://example.test/hooks/woo', ['status' => 'active']); Woocommerce::updateWebhook(2, ['status' => 'paused']); Woocommerce::deleteWebhook(2); ``` -------------------------------- ### Manage customers with Woocommerce facade Source: https://github.com/jeffersongoncalves/laravel-woocommerce/blob/main/README.md Manage customers: list, retrieve, create, update, and delete. The deleteCustomer method accepts a reassign argument; WooCommerce always deletes customers permanently. ```php Woocommerce::listCustomers(['per_page' => 25, 'role' => 'customer']); Woocommerce::getCustomer(25); Woocommerce::createCustomer(['email' => 'jane@example.com', 'first_name' => 'Jane']); Woocommerce::updateCustomer(25, ['last_name' => 'Doe']); Woocommerce::deleteCustomer(25, reassign: 1); // WooCommerce always deletes customers permanently ``` -------------------------------- ### Manage order notes and refunds with Woocommerce facade Source: https://github.com/jeffersongoncalves/laravel-woocommerce/blob/main/README.md Manage order notes and refunds: list, retrieve, create, and delete for each resource. The createOrderNote method accepts a customerNote named argument. ```php Woocommerce::listOrderNotes(727); Woocommerce::getOrderNote(727, 5); Woocommerce::createOrderNote(727, 'Shipped today', customerNote: true); Woocommerce::deleteOrderNote(727, 5); Woocommerce::listRefunds(727); Woocommerce::getRefund(727, 8); Woocommerce::createRefund(727, ['amount' => '10.00', 'reason' => 'Damaged']); Woocommerce::deleteRefund(727, 8); ``` -------------------------------- ### Manage product variations with Woocommerce facade Source: https://github.com/jeffersongoncalves/laravel-woocommerce/blob/main/README.md Manage product variations: list, retrieve, create, update, and delete. The first argument is the parent product ID. ```php Woocommerce::listVariations(99, ['per_page' => 20]); Woocommerce::getVariation(99, 7); Woocommerce::createVariation(99, ['regular_price' => '9.99', 'attributes' => [['id' => 1, 'option' => 'Blue']]]); Woocommerce::updateVariation(99, 7, ['stock_quantity' => 10]); Woocommerce::deleteVariation(99, 7); ``` -------------------------------- ### WooCommerce credentials in .env Source: https://github.com/jeffersongoncalves/laravel-woocommerce/blob/main/README.md Environment variables to add to your .env file. The keys are sent as HTTP Basic credentials, which WooCommerce only accepts over HTTPS. Give the key pair Read access for reporting and Read/Write for mutations. ```env WOOCOMMERCE_BASE_URL=https://example.com WOOCOMMERCE_CONSUMER_KEY=ck_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx WOOCOMMERCE_CONSUMER_SECRET=cs_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ``` -------------------------------- ### Batch write products with Woocommerce::batch Source: https://github.com/jeffersongoncalves/laravel-woocommerce/blob/main/resources/boost/skills/laravel-woocommerce-development/SKILL.md Performs batch create, update, and delete operations on products. WooCommerce limits a batch to 100 objects per request by default. ```php Woocommerce::batch('products', [ 'create' => [['name' => 'Mug', 'regular_price' => '9.90']], 'update' => [['id' => 99, 'regular_price' => '18.90']], 'delete' => [12], ]); ``` -------------------------------- ### Manage coupons with Woocommerce facade Source: https://github.com/jeffersongoncalves/laravel-woocommerce/blob/main/README.md Manage coupons: list, retrieve, create, update, and delete. The deleteCoupon method accepts a force argument to permanently delete. ```php Woocommerce::listCoupons(); Woocommerce::getCoupon(3); Woocommerce::createCoupon(['code' => 'BLACKFRIDAY', 'discount_type' => 'percent', 'amount' => '20']); Woocommerce::updateCoupon(3, ['amount' => '25']); Woocommerce::deleteCoupon(3, force: true); ``` -------------------------------- ### Woocommerce::createProduct(array $attributes) Source: https://github.com/jeffersongoncalves/laravel-woocommerce/blob/main/resources/boost/skills/laravel-woocommerce-development/SKILL.md Creates a new product in WooCommerce. Accepts an array of product attributes and returns an HTTP client response. ```APIDOC ## Woocommerce::createProduct(array $attributes) ### Description Creates a new product in WooCommerce with the given attributes. ### Method POST ### Endpoint Not specified in source. ### Parameters #### Request Body - **name** (string) - Required - Product name - **type** (string) - Required - `simple`, `grouped`, `external`, `variable` - **regular_price** (string) - Required - Price as a string, not a float - **status** (string) - Required - `draft`, `pending`, `private`, `publish` - **categories** (array) - Required - `[['id' => 9]]` - **manage_stock** (bool) - Required - Enable stock management ### Response #### Success Response - **Illuminate\Http\Client\Response** - The HTTP client response from the WooCommerce API. ``` -------------------------------- ### Publish config file with artisan vendor:publish Source: https://github.com/jeffersongoncalves/laravel-woocommerce/blob/main/README.md Publishes the package configuration file to your Laravel config directory. ```bash php artisan vendor:publish --tag="laravel-woocommerce-config" ``` -------------------------------- ### Paginate products with Woocommerce::listProducts Source: https://github.com/jeffersongoncalves/laravel-woocommerce/blob/main/resources/boost/skills/laravel-woocommerce-development/SKILL.md Paginates through all products using the X-WP-TotalPages header. The loop continues until the current page exceeds the total pages returned by WooCommerce. ```php $page = 1; do { $response = Woocommerce::listProducts(['per_page' => 100, 'page' => $page]); // ... handle $response->json() $page++; } while ($page <= (int) $response->header('X-WP-TotalPages')); ``` -------------------------------- ### Test with Http::fake() and Woocommerce::getOrder Source: https://github.com/jeffersongoncalves/laravel-woocommerce/blob/main/resources/boost/skills/laravel-woocommerce-development/SKILL.md Fakes HTTP responses for WooCommerce order endpoints and asserts the request URL. Requires the Http facade and the Woocommerce facade. ```php use Illuminate\Support\Facades\Http; use Jeffersongoncalves\Woocommerce\Facades\Woocommerce; Http::fake(['example.com/wp-json/wc/v3/orders/*' => Http::response(['id' => 727])]); $response = Woocommerce::getOrder(727); Http::assertSent(fn ($request) => $request->url() === 'https://example.com/wp-json/wc/v3/orders/727'); ``` -------------------------------- ### Published config file for laravel-woocommerce Source: https://github.com/jeffersongoncalves/laravel-woocommerce/blob/main/README.md The published config file. It reads WooCommerce credentials from environment variables and defaults the namespace to 'wp-json/wc/v3'. ```php return [ 'base_url' => env('WOOCOMMERCE_BASE_URL'), 'consumer_key' => env('WOOCOMMERCE_CONSUMER_KEY'), 'consumer_secret' => env('WOOCOMMERCE_CONSUMER_SECRET'), 'namespace' => env('WOOCOMMERCE_NAMESPACE', 'wp-json/wc/v3'), ]; ``` -------------------------------- ### Filter orders with Woocommerce::listOrders Source: https://github.com/jeffersongoncalves/laravel-woocommerce/blob/main/resources/boost/skills/laravel-woocommerce-development/SKILL.md Filters orders by status, date, and sorting. WooCommerce caps per_page at 100 and returns X-WP-Total / X-WP-TotalPages headers, so paginate with the page parameter. ```php Woocommerce::listOrders([ 'status' => 'processing', 'per_page' => 100, 'after' => '2026-01-01T00:00:00', 'orderby' => 'date', 'order' => 'desc', ]); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.