Skip to content

Commit cc9d5d7

Browse files
author
WooSignal
committed
New state options for taxes/shipping, Handle variations better, Code clean up, Bug fixes
1 parent 2ae5062 commit cc9d5d7

31 files changed

+875
-592
lines changed

LabelStoreMax/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## [2.0.3] - 2020-05-12
2+
3+
* New state options for taxes/shipping
4+
* Handle variations better
5+
* Code clean up
6+
* Bug fixes
7+
18
## [2.0.2] - 2020-05-08
29

310
* Flutter 1.17.0 support

LabelStoreMax/lang/en.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,5 +142,8 @@
142142
"Sort results": "Sort results",
143143
"you're now logged in": "You're now logged in",
144144
"Hello": "Hello",
145-
"Welcome back": "Welcome back"
145+
"Welcome back": "Welcome back",
146+
"Quantity": "Quantity",
147+
"Select a state": "Select a state",
148+
"Select state": "Select state"
146149
}
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
// Label StoreMAX
2+
//
3+
// Created by Anthony Gordon.
4+
// 2020, WooSignal Ltd. All rights reserved.
5+
//
6+
7+
// Unless required by applicable law or agreed to in writing, software
8+
// distributed under the License is distributed on an "AS IS" BASIS,
9+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
11+
// STATE OPTIONS
12+
// ONLY USED IF COUNTRY IS US
13+
14+
var appStateOptions = [
15+
{"code": "AL", "name": "Alabama"},
16+
{"code": "AK", "name": "Alaska"},
17+
{"code": "AS", "name": "American Samoa"},
18+
{"code": "AZ", "name": "Arizona"},
19+
{"code": "AR", "name": "Arkansas"},
20+
{"code": "CA", "name": "California"},
21+
{"code": "CO", "name": "Colorado"},
22+
{"code": "CT", "name": "Connecticut"},
23+
{"code": "DE", "name": "Delaware"},
24+
{"code": "DC", "name": "District Of Columbia"},
25+
{"code": "FM", "name": "Federated States Of Micronesia"},
26+
{"code": "FL", "name": "Florida"},
27+
{"code": "GA", "name": "Georgia"},
28+
{"code": "GU", "name": "Guam"},
29+
{"code": "HI", "name": "Hawaii"},
30+
{"code": "ID", "name": "Idaho"},
31+
{"code": "IL", "name": "Illinois"},
32+
{"code": "IN", "name": "Indiana"},
33+
{"code": "IA", "name": "Iowa"},
34+
{"code": "KS", "name": "Kansas"},
35+
{"code": "KY", "name": "Kentucky"},
36+
{"code": "LA", "name": "Louisiana"},
37+
{"code": "ME", "name": "Maine"},
38+
{"code": "MH", "name": "Marshall Islands"},
39+
{"code": "MD", "name": "Maryland"},
40+
{"code": "MA", "name": "Massachusetts"},
41+
{"code": "MI", "name": "Michigan"},
42+
{"code": "MN", "name": "Minnesota"},
43+
{"code": "MS", "name": "Mississippi"},
44+
{"code": "MO", "name": "Missouri"},
45+
{"code": "MT", "name": "Montana"},
46+
{"code": "NE", "name": "Nebraska"},
47+
{"code": "NV", "name": "Nevada"},
48+
{"code": "NH", "name": "New Hampshire"},
49+
{"code": "NJ", "name": "New Jersey"},
50+
{"code": "NM", "name": "New Mexico"},
51+
{"code": "NY", "name": "New York"},
52+
{"code": "NC", "name": "North Carolina"},
53+
{"code": "ND", "name": "North Dakota"},
54+
{"code": "MP", "name": "Northern Mariana Islands"},
55+
{"code": "OH", "name": "Ohio"},
56+
{"code": "OK", "name": "Oklahoma"},
57+
{"code": "OR", "name": "Oregon"},
58+
{"code": "PW", "name": "Palau"},
59+
{"code": "PA", "name": "Pennsylvania"},
60+
{"code": "PR", "name": "Puerto Rico"},
61+
{"code": "RI", "name": "Rhode Island"},
62+
{"code": "SC", "name": "South Carolina"},
63+
{"code": "SD", "name": "South Dakota"},
64+
{"code": "TN", "name": "Tennessee"},
65+
{"code": "TX", "name": "Texas"},
66+
{"code": "UT", "name": "Utah"},
67+
{"code": "VT", "name": "Vermont"},
68+
{"code": "VI", "name": "Virgin Islands"},
69+
{"code": "VA", "name": "Virginia"},
70+
{"code": "WA", "name": "Washington"},
71+
{"code": "WV", "name": "West Virginia"},
72+
{"code": "WI", "name": "Wisconsin"},
73+
{"code": "WY", "name": "Wyoming"}
74+
];

LabelStoreMax/lib/helpers/app_themes.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ TextTheme textThemeAccent() {
6363

6464
TextTheme textThemePrimary() {
6565
return TextTheme(
66-
headline4: new TextStyle(
66+
headline4: new TextStyle(
6767
color: Colors.black,
6868
fontFamily: appFontFamily,
6969
fontWeight: FontWeight.w800,
@@ -112,7 +112,7 @@ TextTheme textThemePrimary() {
112112

113113
TextTheme textThemeMain() {
114114
return TextTheme(
115-
headline4: new TextStyle(
115+
headline4: new TextStyle(
116116
color: Colors.black,
117117
fontFamily: appFontFamily,
118118
),
@@ -132,7 +132,7 @@ TextTheme textThemeMain() {
132132

133133
TextTheme textThemeAppBar() {
134134
return TextTheme(
135-
headline4: new TextStyle(color: Colors.black, fontFamily: appFontFamily),
135+
headline4: new TextStyle(color: Colors.black, fontFamily: appFontFamily),
136136
headline3: new TextStyle(color: Colors.black, fontFamily: appFontFamily),
137137
headline2: new TextStyle(color: Colors.black, fontFamily: appFontFamily),
138138
headline1: new TextStyle(color: Colors.black, fontFamily: appFontFamily),

LabelStoreMax/lib/labelconfig.dart

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,17 @@ import 'dart:ui';
1616
Developer Notes
1717
1818
SUPPORT EMAIL - support@woosignal.com
19-
VERSION - 2.0.2
19+
VERSION - 2.0.3
2020
https://woosignal.com
2121
*/
2222

2323
/*<! ------ CONFIG ------!>*/
2424

2525
const app_name = "MyApp";
2626

27-
const app_key = "Your app key from WooSingal";
27+
//const app_key = "Your app key from WooSignal";
28+
const app_key =
29+
"app_affb6434339b34443a297c2e40a3edab7102137e6d67de9abfe612b749bd";
2830
// Your App key from WooSignal
2931
// link: https://woosignal.com/dashboard/apps
3032

@@ -33,7 +35,6 @@ const app_logo_url = "https://woosignal.com/images/120x120_woosignal.png";
3335
const app_terms_url = "https://yourdomain.com/terms";
3436
const app_privacy_url = "https://yourdomain.com/privacy";
3537

36-
3738
/*<! ------ APP SETTINGS ------!>*/
3839

3940
const app_currency_symbol = "";
@@ -45,15 +46,13 @@ const app_locales_supported = [
4546
// then create a new lang json file using keys from en.json
4647
// e.g. lang/es.json
4748

48-
4949
/*<! ------ PAYMENT GATEWAYS ------!>*/
5050

5151
// Available: "Stripe", "CashOnDelivery",
5252
// Add the method to the array below e.g. ["Stripe", "CashOnDelivery"]
5353

5454
const app_payment_methods = ["Stripe"];
5555

56-
5756
/*<! ------ STRIPE (OPTIONAL) ------!>*/
5857

5958
// Your StripeAccount key from WooSignal
@@ -67,7 +66,6 @@ const app_stripe_live_mode = false;
6766
// #2 Next visit https://woosignal.com/dashboard
6867
// #3 Then change "Environment for Stripe" to Live mode
6968

70-
7169
/*<! ------ WP LOGIN (OPTIONAL) ------!>*/
7270

7371
// Allows customers to login/register, view account, purchase items as a user.
@@ -81,7 +79,6 @@ const app_forgot_password_url =
8179
"https://mysite.com/my-account/lost-password"; // change to your forgot password url
8280
const app_wp_api_path = "/wp-json"; // By default "/wp-json" should work
8381

84-
8582
/*<! ------ DEBUGGER ENABLED ------!>*/
8683

8784
const app_debug = true;

LabelStoreMax/lib/models/cart.dart

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,22 @@ class Cart {
4141

4242
void addToCart({CartLineItem cartLineItem}) async {
4343
List<CartLineItem> cartLineItems = await getCart();
44-
var firstCartItem = cartLineItems.firstWhere(
45-
(i) =>
46-
i.productId == cartLineItem.productId ||
47-
i.productId == cartLineItem.productId &&
48-
i.variationId == cartLineItem.variationId, orElse: () {
49-
return null;
50-
});
51-
if (firstCartItem != null) {
52-
return;
44+
45+
if (cartLineItem.variationId != null) {
46+
if (cartLineItems.firstWhere(
47+
(i) => (i.productId == cartLineItem.productId &&
48+
i.variationId == cartLineItem.variationId),
49+
orElse: () => null) !=
50+
null) {
51+
return;
52+
}
53+
} else {
54+
var firstCartItem = cartLineItems.firstWhere(
55+
(i) => i.productId == cartLineItem.productId,
56+
orElse: () => null);
57+
if (firstCartItem != null) {
58+
return;
59+
}
5360
}
5461
cartLineItems.add(cartLineItem);
5562

@@ -60,7 +67,7 @@ class Cart {
6067
List<CartLineItem> cartLineItems = await getCart();
6168
double total = 0;
6269
cartLineItems.forEach((cartItem) {
63-
total += (double.parse(cartItem.total) * cartItem.quantity);
70+
total += (parseWcPrice(cartItem.total) * cartItem.quantity);
6471
});
6572

6673
if (withFormat != null && withFormat == true) {
@@ -73,7 +80,7 @@ class Cart {
7380
List<CartLineItem> cartLineItems = await getCart();
7481
double subtotal = 0;
7582
cartLineItems.forEach((cartItem) {
76-
subtotal += (double.parse(cartItem.subtotal) * cartItem.quantity);
83+
subtotal += (parseWcPrice(cartItem.subtotal) * cartItem.quantity);
7784
});
7885
if (withFormat != null && withFormat == true) {
7986
return formatDoubleCurrency(total: subtotal);
@@ -133,6 +140,7 @@ class Cart {
133140
double shippingTotal = 0;
134141

135142
List<CartLineItem> cartItems = await Cart.getInstance.getCart();
143+
136144
if (cartItems.every((c) => c.taxStatus == 'none')) {
137145
return "0";
138146
}

LabelStoreMax/lib/models/customer_address.dart

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class CustomerAddress {
1414
String addressLine;
1515
String city;
1616
String postalCode;
17+
String state;
1718
String country;
1819
String emailAddress;
1920

@@ -23,6 +24,7 @@ class CustomerAddress {
2324
this.addressLine,
2425
this.city,
2526
this.postalCode,
27+
this.state,
2628
this.country,
2729
this.emailAddress});
2830

@@ -32,30 +34,35 @@ class CustomerAddress {
3234
addressLine = "";
3335
city = "";
3436
postalCode = "";
37+
state = "";
3538
country = "";
3639
emailAddress = "";
3740
}
3841

3942
bool hasMissingFields() {
4043
return (this.firstName.isEmpty ||
41-
this.lastName.isEmpty ||
42-
this.addressLine.isEmpty ||
43-
this.city.isEmpty ||
44-
this.postalCode.isEmpty);
44+
this.lastName.isEmpty ||
45+
this.addressLine.isEmpty ||
46+
this.city.isEmpty ||
47+
this.postalCode.isEmpty) &&
48+
(this.country == "United States" ? this.state.isEmpty : false);
4549
}
4650

4751
String addressFull() {
4852
List<String> tmpArrAddress = new List<String>();
49-
if (addressLine != "") {
53+
if (addressLine != null && addressLine != "") {
5054
tmpArrAddress.add(addressLine);
5155
}
52-
if (city != "") {
56+
if (city != null && city != "") {
5357
tmpArrAddress.add(city);
5458
}
55-
if (postalCode != "") {
59+
if (postalCode != null && postalCode != "") {
5660
tmpArrAddress.add(postalCode);
5761
}
58-
if (country != "") {
62+
if (state != null && state != "") {
63+
tmpArrAddress.add(state);
64+
}
65+
if (country != null && country != "") {
5966
tmpArrAddress.add(country);
6067
}
6168
return tmpArrAddress.join(", ");
@@ -78,6 +85,7 @@ class CustomerAddress {
7885
addressLine = json['address_line'];
7986
city = json['city'];
8087
postalCode = json['postal_code'];
88+
state = json['state'];
8189
country = json['country'];
8290
emailAddress = json['email_address'];
8391
}
@@ -89,6 +97,7 @@ class CustomerAddress {
8997
data['address_line'] = this.addressLine;
9098
data['city'] = this.city;
9199
data['postal_code'] = this.postalCode;
100+
data['state'] = this.state;
92101
data['country'] = this.country;
93102
data['email_address'] = this.emailAddress;
94103
return data;

LabelStoreMax/lib/pages/about.dart

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,7 @@ class _AboutPageState extends State<AboutPage> {
3737
backgroundColor: Colors.transparent,
3838
leading: IconButton(
3939
icon: Icon(Icons.close),
40-
onPressed: () {
41-
Navigator.pop(context);
42-
},
40+
onPressed: () => Navigator.pop(context),
4341
),
4442
title: Text(trans(context, "About"),
4543
style: Theme.of(context).primaryTextTheme.headline6),
@@ -60,14 +58,18 @@ class _AboutPageState extends State<AboutPage> {
6058
crossAxisAlignment: CrossAxisAlignment.center,
6159
mainAxisAlignment: MainAxisAlignment.spaceAround,
6260
children: <Widget>[
63-
wsMenuItem(context,
64-
title: trans(context, "Privacy policy"),
65-
leading: Icon(Icons.people),
66-
action: _actionPrivacy),
67-
wsMenuItem(context,
68-
title: trans(context, "Terms and conditions"),
69-
leading: Icon(Icons.description),
70-
action: _actionTerms),
61+
wsMenuItem(
62+
context,
63+
title: trans(context, "Privacy policy"),
64+
leading: Icon(Icons.people),
65+
action: _actionPrivacy,
66+
),
67+
wsMenuItem(
68+
context,
69+
title: trans(context, "Terms and conditions"),
70+
leading: Icon(Icons.description),
71+
action: _actionTerms,
72+
),
7173
FutureBuilder<PackageInfo>(
7274
future: PackageInfo.fromPlatform(),
7375
builder: (BuildContext context,
@@ -93,7 +95,7 @@ class _AboutPageState extends State<AboutPage> {
9395
}
9496
return null; // unreachable
9597
},
96-
)
98+
),
9799
],
98100
),
99101
flex: 2,

LabelStoreMax/lib/pages/account_billing_details.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,7 @@ class _AccountBillingDetailsPageState extends State<AccountBillingDetailsPage> {
9696
body: SafeArea(
9797
minimum: safeAreaDefault(),
9898
child: GestureDetector(
99-
onTap: () {
100-
FocusScope.of(context).requestFocus(new FocusNode());
101-
},
99+
onTap: () => FocusScope.of(context).requestFocus(new FocusNode()),
102100
child: _isLoading
103101
? showAppLoader()
104102
: LayoutBuilder(

0 commit comments

Comments
 (0)