mergeGuestCart method
Merge guest cart with customer cart
Implementation
Future<Cart> mergeGuestCart(String customerId) async {
try {
final response = await _client.authenticatedRequest<Map<String, dynamic>>(
'/rest/V1/carts/mine/merge',
options: Options(method: 'POST'),
data: {'customer_id': customerId},
);
if (response.statusCode == 200) {
return Cart.fromJson(response.data!);
} else {
throw Exception(
'Failed to merge guest cart: ${response.statusMessage}',
);
}
} on DioException catch (e) {
throw Exception('Failed to merge guest cart: ${e.message}');
} catch (e) {
throw Exception('Failed to merge guest cart: $e');
}
}