{"id":32304975,"url":"https://github.com/loaidev64/woocommerce_flutter_api","last_synced_at":"2026-02-27T11:44:40.063Z","repository":{"id":228353450,"uuid":"773760839","full_name":"loaidev64/woocommerce_flutter_api","owner":"loaidev64","description":"Woocommerce flutter api integration with external plugin created by loaidev64@gmail.com and published by amjadqasem07@gmail.com.","archived":false,"fork":false,"pushed_at":"2025-11-08T13:07:04.000Z","size":2382,"stargazers_count":9,"open_issues_count":3,"forks_count":8,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-11-08T14:51:55.871Z","etag":null,"topics":["dart","dio","flutter","rest-api","restful-api","woocommerce"],"latest_commit_sha":null,"homepage":"","language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/loaidev64.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-03-18T10:56:33.000Z","updated_at":"2025-11-08T13:07:08.000Z","dependencies_parsed_at":"2024-03-18T11:55:32.528Z","dependency_job_id":"932e6122-58b5-41d0-9af4-b60aa3e22620","html_url":"https://github.com/loaidev64/woocommerce_flutter_api","commit_stats":null,"previous_names":["loaidev64/woocommerce_flutter_api"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/loaidev64/woocommerce_flutter_api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loaidev64%2Fwoocommerce_flutter_api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loaidev64%2Fwoocommerce_flutter_api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loaidev64%2Fwoocommerce_flutter_api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loaidev64%2Fwoocommerce_flutter_api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/loaidev64","download_url":"https://codeload.github.com/loaidev64/woocommerce_flutter_api/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loaidev64%2Fwoocommerce_flutter_api/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29892357,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-27T09:48:51.284Z","status":"ssl_error","status_checked_at":"2026-02-27T09:48:43.992Z","response_time":57,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dart","dio","flutter","rest-api","restful-api","woocommerce"],"created_at":"2025-10-23T06:42:44.548Z","updated_at":"2026-02-27T11:44:40.047Z","avatar_url":"https://github.com/loaidev64.png","language":"Dart","readme":"# WooCommerce Flutter API\n\nA comprehensive Flutter package for seamless WooCommerce integration. Easily manage authentication, notifications, cart, and product data with updated dependencies and full documentation.\n\n## Dependencies\n\nThis package leverages the following dependencies:\n\n- [dio](https://pub.dev/packages/dio) (^5.9.0) for HTTP requests\n- [faker](https://pub.dev/packages/faker) (^2.2.0) for generating fake data during development\n- [flutter_secure_storage](https://pub.dev/packages/flutter_secure_storage) (^9.2.4) for secure data storage\n- [pretty_dio_logger](https://pub.dev/packages/pretty_dio_logger) (^1.4.0) for logging HTTP requests in a readable format\n\n## Installation\n\nTo install the package, run:\n\n```bash\nflutter pub add woocommerce_flutter_api\n```\n\n## Usage\n\nCreate the main WooCommerce object to access all the features of the package:\n\n```dart\nfinal woocommerce = WooCommerce(\n  baseUrl: '\u003cwoocommerce-url\u003e', \n  username: '\u003cusername\u003e', \n  password: '\u003cpassword\u003e', \n  useFaker: true,\n  isDebug: true, // true by default\n  apiPath: '\u003csome-custom-path\u003e',\n  interceptors: [\n      // DioCacheInterceptor(),\n  ],\n);\n```\n### Using Fake Data (`useFaker`)\n\nThe `useFaker` property is designed for development and testing purposes. When set to `true`, all API requests will return fake data generated by the [faker](https://pub.dev/packages/faker) package. This is especially useful if your WooCommerce backend is still under development—allowing you to build and test your application without relying on live data. Once your backend is ready, simply set `useFaker` to `false` to receive real data.\n\nExample of initializing with fake data enabled:\n\n```dart\nfinal woocommerce = WooCommerce(\n  baseUrl: '\u003cwoocommerce-url\u003e', \n  username: '\u003cusername\u003e', \n  password: '\u003cpassword\u003e', \n  useFaker: true,\n  isDebug: true, // true by default\n  apiPath: '\u003csome-custom-path\u003e',\n  interceptors: [\n      // DioCacheInterceptor(),\n  ],\n);\n```\n\nIn this mode, every API call (e.g., authentication, notifications, cart, products) will return simulated responses, allowing you to continue development seamlessly until your WooCommerce backend is published.\n\n### Authentication\n\nLogin and securely store the user ID:\n\n```dart\ntry {\n  await woocommerce.login('\u003cemail\u003e', '\u003cpassword\u003e');\n  // Login successful, user ID is stored securely\n} catch (e) {\n  // Handle login error\n  print('Login failed: $e');\n}\n```\n\n### Notifications\n\nFetch all notifications for the currently logged in user:\n\n```dart\ntry {\n  final notifications = await woocommerce.getNotifications();\n  // Process the list of notifications\n  notifications.forEach((notification) {\n    print('Notification: ${notification.message}'); \n  });\n} catch (e) {\n  // Handle error fetching notifications\n  print('Error fetching notifications: $e');\n}\n```\n\n### Cart\n\nRetrieve the cart for the current user:\n\n```dart\ntry {\n  final cart = await woocommerce.getCart();\n  // Process cart data\n  print('Cart Total: ${cart.totals?.totalPrice}');\n  cart.items?.forEach((item) {\n    print('Item: ${item.name}, Quantity: ${item.quantity}');\n  });\n} catch (e) {\n  // Handle error fetching cart\n  print('Error fetching cart: $e');\n}\n```\n\n### WooCommerce API\n\n#### Fetching a List of Products\n\nRetrieve a paginated list of products with various filtering options:\n\n```dart\ntry {\n  // Fetch the first 10 published products, ordered by title ascending\n  final products = await woocommerce.getProducts(\n    perPage: 10,\n    page: 1,\n    status: WooFilterStatus.publish,\n    orderBy: WooSortOrderBy.title,\n    order: WooSortOrder.asc,\n  );\n  // Process the list of products\n  products.forEach((product) {\n    print('Product: ${product.name} - Price: ${product.price}');\n  });\n} catch (e) {\n  // Handle error fetching products\n  print('Error fetching products: $e');\n}\n```\n\n#### Fetching a Single Product by ID\n\nRetrieve details for a specific product using its ID:\n\n```dart\ntry {\n  final productId = 123; // Replace with the actual product ID\n  final product = await woocommerce.getProduct(productId);\n  // Process the product details\n  print('Fetched Product: ${product.name}');\n  print('Description: ${product.description}');\n} catch (e) {\n  // Handle error fetching single product\n  print('Error fetching product $productId: $e');\n}\n```\n\n#### Fetching Products with Related Data (`getProductWithOptions`)\n\nOften, when displaying a product detail screen, you need not only the main product data but also related information like variations, upsells, cross-sells, or grouped products. Making separate API calls for each of these can be inefficient.\n\nThe `getProductWithOptions` method solves this by fetching the main product *and* specified related products in a single, optimized request.\n\n**When to Use:**\n\nUse this method typically on a product detail screen. After a user navigates from a product list (where you might have used `getProducts`) to view a specific item, call `getProductWithOptions` to gather all necessary data for that view efficiently.\n\n**How it Works:**\n\nYou provide an already fetched `WooProduct` object and a list of `WooProductFilterWithType` enums specifying which related data you need (e.g., `variations`, `upsellIds`, `relatedIds`). The method returns a `WooProductWithChildrens` object containing the `mainProduct` and lists of the requested related products.\n\n**Example:**\n\nAssume you have a `selectedProduct` object (fetched previously) and you want to display its details along with its variations and upsell products.\n\n```dart\n// Assuming 'selectedProduct' is a WooProduct object you already have\n// and 'woocommerce' is your initialized WooCommerce instance.\n\ntry {\n  // Specify the related data types you need\n  final optionsToFetch = [\n    WooProductFilterWithType.variations, // Fetch product variations\n    WooProductFilterWithType.upsellIds,  // Fetch upsell products\n    WooProductFilterWithType.relatedIds, // Fetch related products\n  ];\n\n  final productWithDetails = await woocommerce.getProductWithOptions(\n    selectedProduct,\n    optionsToFetch,\n  );\n\n  // Now you can access the main product and the fetched related data\n  print('Main Product: ${productWithDetails.mainProduct.name}');\n\n  if (productWithDetails.variations != null \u0026\u0026 productWithDetails.variations!.isNotEmpty) {\n    print('--- Variations ---');\n    productWithDetails.variations!.forEach((variation) {\n      print('Variation: ${variation.name} - Price: ${variation.price}');\n      // Display variation attributes, price, etc.\n    });\n  }\n\n  if (productWithDetails.upsellProducts != null \u0026\u0026 productWithDetails.upsellProducts!.isNotEmpty) {\n    print('--- Upsell Products ---');\n    productWithDetails.upsellProducts!.forEach((upsell) {\n      print('Upsell: ${upsell.name}');\n      // Display upsell products (e.g., in a carousel)\n    });\n  }\n  \n  if (productWithDetails.relatedProducts != null \u0026\u0026 productWithDetails.relatedProducts!.isNotEmpty) {\n    print('--- Related Products ---');\n    productWithDetails.relatedProducts!.forEach((related) {\n      print('Related: ${related.name}');\n      // Display related products\n    });\n  }\n\n} catch (e) {\n  // Handle errors fetching product details\n  print('Error fetching product with options: $e');\n}\n```\n\nThis approach significantly reduces the number of network requests compared to fetching each piece of related data separately.\n\n#### Product Variations API\n\nRetrieve and manage product variations:\n\n```dart\ntry {\n  // Get all variations for a product\n  final variations = await woocommerce.getProductVaritaions(productId: 123);\n  \n  // Get a specific variation\n  final variation = await woocommerce.getProductVariation(\n    productId: 123,\n    id: 456,\n  );\n  \n  // Search variations with filters\n  final filteredVariations = await woocommerce.getProductVaritaions(\n    productId: 123,\n    search: 'red',\n    stockStatus: WooProductStockStatus.instock,\n    minPrice: 10.0,\n    maxPrice: 100.0,\n  );\n  \n  variations.forEach((variation) {\n    print('Variation: ${variation.name} - Price: ${variation.price}');\n  });\n} catch (e) {\n  print('Error fetching variations: $e');\n}\n```\n\n#### Making Custom API Calls\n\nWhile this package aims to cover the most common WooCommerce REST API endpoints, you might encounter scenarios where you need to:\n\n1.  Call an endpoint not yet implemented by this package.\n2.  Interact with custom endpoints added by other WooCommerce plugins.\n\nFor these cases, the package exposes the configured `Dio` instance directly via `woocommerce.dio`. This allows you to make arbitrary HTTP requests to your WooCommerce site, leveraging the base URL, authentication headers, and logging interceptor already set up by the `WooCommerce` class.\n\n**Example:**\n\nLet's say you need to fetch data from a custom endpoint `/wp-json/my-custom-plugin/v1/data` added by another plugin.\n\n```dart\nimport 'package:dio/dio.dart'; // Import Dio\n\n// Assuming 'woocommerce' is your initialized WooCommerce instance.\n\nfinal customEndpoint = '/my-custom-plugin/v1/data'; // Relative path to the custom endpoint\n\ntry {\n  // Use the exposed dio instance for the custom GET request\n  final response = await woocommerce.dio.get(\n    customEndpoint,\n    queryParameters: {\n      'filter': 'some_value', // Add any necessary query parameters\n      'limit': 5,\n    },\n  );\n\n  // Check if the request was successful (status code 2xx)\n  if (response.statusCode! \u003e= 200 \u0026\u0026 response.statusCode! \u003c 300) {\n    // Process the response data (likely a Map or List)\n    print('Custom API Response: ${response.data}');\n    // You might need to parse response.data into your custom Dart models\n  } else {\n    // Handle non-successful status codes\n    print('Custom API request failed with status: ${response.statusCode}');\n    print('Response body: ${response.data}');\n  }\n\n} on DioException catch (e) {\n  // Handle Dio-specific errors (network issues, timeouts, etc.)\n  print('Dio error calling custom endpoint $customEndpoint: $e');\n  if (e.response != null) {\n    // The server responded with an error status code\n    print('Error response data: ${e.response?.data}');\n  } else {\n    // Error setting up or sending the request\n    print('Error message: ${e.message}');\n  }\n} catch (e) {\n  // Handle any other unexpected errors\n  print('Unexpected error calling custom endpoint $customEndpoint: $e');\n}\n```\n\nUsing `woocommerce.dio` gives you the flexibility to interact with any part of the WooCommerce REST API (or related custom APIs) directly, while still benefiting from the package's setup for authentication and base URL configuration. Remember to consult the WooCommerce REST API documentation or the documentation of the specific plugin for details on available endpoints, parameters, and expected response formats.\n\n## Roadmap  \n\nThis package is actively being developed, and the following features have been implemented so far:  \n\n### Implemented Features ✅  \n- Authentication (Login \u0026 Secure Storage)  \n- Fetching Notifications  \n- Managing Cart (Retrieve user cart)  \n- Fetching Products  \n- Order Management (Retrieve, Create, Update, and Delete orders)  \n- Product Tags API (Get, Create, Update, Delete product tags)  \n- Coupon Management (Retrieve, Create, Update, and Delete coupons)  \n- Customer Management (Retrieve, Create, Update, and Delete customers)  \n- Order Additional Features (actions, notes, refunds)  \n- Product Additional Features (shipping classes, reviews)  \n- Reports API\n- Tax rates API\n- Tax classes API\n- Refunds API\n- Webhook API\n- Settings API\n- Setting Options API\n- Payment Gateways API\n- Shipping API (zones, locations, methods)\n- System status API \n- System status tools API \n- Data API \n- Exposed `dio` instance for custom API calls\n\n### Upcoming Features 🚀  \n- Better documentation\n\n## Contributing\n\nContributions are welcome! If you have suggestions, bug fixes, or improvements, please open an issue or submit a pull request. Your contributions will help make this package even better.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Floaidev64%2Fwoocommerce_flutter_api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Floaidev64%2Fwoocommerce_flutter_api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Floaidev64%2Fwoocommerce_flutter_api/lists"}