Coupon.fromOpencartJson constructor

Coupon.fromOpencartJson(
  1. Map<String, dynamic> json
)

Implementation

Coupon.fromOpencartJson(Map<String, dynamic> json) {
  try {
    amount = double.parse(json['discount'].toString());
    code = json['code'];
    id = json['coupon_id'];
    discountType = json['type'] == 'P' ? 'percent' : 'fixed_cart';
    description = json['name'];
    minimumAmount =
        json['total'] != null ? double.parse(json['total'].toString()) : 0.0;
    maximumAmount = 0.0;
    dateExpires = DateTime.parse(json['date_end']);
    message = '';
  } catch (e) {
    // ignore: avoid_print
    print(e.toString());
  }
}