getMyCart method

Future<WooCart> getMyCart()

Returns the current user's WooCart, information

Implementation

Future<WooCart> getMyCart() async {
  await getAuthTokenFromDb();
  _urlHeader['Authorization'] = 'Bearer ' + _authToken!;
  WooCart cart;
  final response = await http.get(
      Uri.parse(this.baseUrl + URL_STORE_API_PATH + 'cart'),
      headers: _urlHeader);
  _printToLog('response gotten : ' + response.toString());
  if (response.statusCode >= 200 && response.statusCode < 300) {
    final jsonStr = json.decode(response.body);
    cart = WooCart.fromJson(jsonStr);
    return cart;
  } else {
    _printToLog(' error : ' + response.body);
    WooCommerceError err =
        WooCommerceError.fromJson(json.decode(response.body));
    throw err;
  }
}