WooCommerce class
A connection to one WooCommerce store.
final woo = WooCommerce(
baseUrl: 'https://shop.example.com',
credentials: const WooCredentials.key(
consumerKey: 'ck_…',
consumerSecret: 'cs_…',
),
);
final page = await woo.products.list(perPage: 20);
Close it when you are done, or pass your own http.Client and manage that
instead — a client left open keeps its connections alive.
Constructors
- WooCommerce({required String baseUrl, WooCredentials credentials = const WooCredentials.none(), String apiPath = '/wp-json/wc/v3', Client? httpClient, Duration timeout = const Duration(seconds: 30), WooRetry retry = const WooRetry.none()})
-
Connects to the store at
baseUrl.
Properties
- admin → WooAdminResources
-
Everything else the admin API exposes: categories, tags, attributes,
reviews, shipping, tax, reports, settings, webhooks, system status.
latefinal
- apiPath → String
-
Where the REST route lives, relative to the site root.
final
- coupons → WooCoupons
-
Discount codes.
latefinal
- credentials → WooCredentials
-
How this client proves who it is.
final
- customers → WooCustomers
-
Customer accounts.
latefinal
- hashCode → int
-
The hash code for this object.
no setterinherited
- orders → WooOrders
-
Orders: listing, placing, and moving through statuses.
latefinal
- products → WooProducts
-
Products, variations, and the queries over them.
latefinal
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- timeout → Duration
-
How long to wait for the store before giving up.
final
Methods
-
close(
) → void - Releases the underlying connection, if this client made it.
-
delete(
String path, {bool force = false, Map< String, Object?> ? query}) → Future<Map< String, Object?> > - Sends a DELETE and decodes a single object.
-
getOne(
String path, {Map< String, Object?> ? query}) → Future<Map< String, Object?> > - Sends a GET and decodes a single object.
-
getPage(
String path, {Map< String, Object?> ? query, int page = 1, int perPage = 10}) → Future<WooPage< Map< >String, Object?> > - Sends a GET and decodes a list, with the store's paging headers.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
post(
String path, Map< String, Object?> body, {Map<String, Object?> ? query}) → Future<Map< String, Object?> > - Sends a POST and decodes a single object.
-
put(
String path, Map< String, Object?> body, {Map<String, Object?> ? query}) → Future<Map< String, Object?> > - Sends a PUT and decodes a single object.
-
putList(
String path, List< Object?> body) → Future<List< Map< >String, Object?> > - Sends a PUT whose body is a JSON array, and decodes an array back.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited