getProductShippingClasses method
Returns a list of all WooProductShippingClass, with filter options.
Related endpoint: https://woocommerce.github.io/woocommerce-rest-api-docs/#product-shipping-classes
Implementation
Future<List<WooProductShippingClass>> getProductShippingClasses(
{int? page,
int? perPage,
String? search,
List<int>? exclude,
List<int>? include,
int? offset,
String? order,
String? orderBy,
bool? hideEmpty,
int? product,
String? slug}) async {
Map<String, dynamic> payload = {};
({
'page': page,
'per_page': perPage,
'search': search,
'exclude': exclude,
'include': include,
'offset': offset,
'order': order,
'orderby': orderBy,
'hide_empty': hideEmpty,
'product': product,
'slug': slug,
}).forEach((k, v) {
if (v != null) payload[k] = v.toString();
});
List<WooProductShippingClass> productShippingClasses = [];
_setApiResourceUrl(
path: 'products/shipping_classes',
);
final response = await get(queryUri.toString());
_printToLog('response gotten : ' + response.toString());
for (var c in response) {
var sClass = WooProductShippingClass.fromJson(c);
_printToLog('prod gotten here : ' + sClass.toString());
productShippingClasses.add(sClass);
}
return productShippingClasses;
}