v1.0.12 customer properties and membership

This commit is contained in:
Tibor Bossanyi
2023-03-01 17:44:41 +01:00
parent 6ac35b67ab
commit 31717c6c5e
9 changed files with 193 additions and 25 deletions
+30
View File
@@ -566,4 +566,34 @@ class CustomerRepository with Logging {
}
return allProperties;
}
void initCustomerProperties() {
List<Property>? properties = Cache().getProperties();
Customer? customer = Cache().userLoggedIn;
if (customer == null || customer.customerProperties.isEmpty || properties == null) {
return;
}
for (var property in properties) {
CustomerProperty? customerProperty = getCustomerPropertyById(property.propertyId);
if (customerProperty != null) {
customer.properties[property.propertyName] = customerProperty;
}
}
}
CustomerProperty? getCustomerPropertyById(int id) {
CustomerProperty? property;
Customer? customer = Cache().userLoggedIn;
if (customer == null) {
return property;
}
for (var customerProperty in customer.customerProperties) {
if (customerProperty.propertyId == id) {
property = customerProperty;
break;
}
}
return property;
}
}