getProductAttributeTerms method
Returns a list of all WooProductAttributeTerm, with filter options.
Related endpoint: https://woocommerce.github.io/woocommerce-rest-api-docs/#product-attribute-terms
Implementation
Future<List<WooProductAttributeTerm>> getProductAttributeTerms(
{required int attributeId,
int? page,
int? perPage,
String? search,
List<int>? exclude,
List<int>? include,
String? order,
String? orderBy,
bool? hideEmpty,
int? parent,
int? product,
String? slug}) async {
Map<String, dynamic> payload = {};
({
'page': page,
'per_page': perPage,
'search': search,
'exclude': exclude,
'include': include,
'order': order,
'orderby': orderBy,
'hide_empty': hideEmpty,
'parent': parent,
'product': product,
'slug': slug,
}).forEach((k, v) {
if (v != null) payload[k] = v.toString();
});
List<WooProductAttributeTerm> productAttributeTerms = [];
_setApiResourceUrl(
path: 'products/attributes/' + attributeId.toString() + '/terms',
queryParameters: payload);
final response = await get(queryUri.toString());
for (var t in response) {
var term = WooProductAttributeTerm.fromJson(t);
_printToLog('term gotten here : ' + term.toString());
productAttributeTerms.add(term);
}
return productAttributeTerms;
}