setDataToCalculate function
Implementation
setDataToCalculate(OrderData? orderData, ProductData? _productData){
productData = ProductData.createEmpty();
if (_productData != null)
productData = _productData;
if (orderData != null) {
couponId = orderData.couponId;
discountType = orderData.discountType;
couponCode = orderData.couponName;
discount = orderData.discount;
countProduct = orderData.count;
productData = ProductData("", [], gallery: [],
desc: [],
descTitle: [],
duration: Duration(),
category: [],
timeModify: DateTime.now(),
providers: [],
countProduct: orderData.count,
tax: orderData.tax,
price: [
PriceData(orderData.priceName, orderData.price, orderData.discPrice,
orderData.priceUnit, ImageData(serverPath: "", localFile: ""))
],
addon: orderData.addon, group: [],
);
}
price = PriceData.createEmpty();
if (productData.price.isNotEmpty) {
if (productData.price.length == 1)
price = productData.price[0];
else {
for (var item in productData.price)
if (item.selected)
price = item;
}
}
productData.countProduct = countProduct;
}