Skip to content

Commit

Permalink
Merge pull request #34 from woosignal/master
Browse files Browse the repository at this point in the history
v5.8.0 updates
  • Loading branch information
agordn52 authored Mar 29, 2022
2 parents 3c1f023 + c72cc32 commit 249f987
Show file tree
Hide file tree
Showing 11 changed files with 150 additions and 114 deletions.
6 changes: 6 additions & 0 deletions LabelStoreMax/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## [5.8.0] - 2022-03-29

* Add phone number to customer input form
* Gradle version bump
* Pubspec.yaml dependency updates

## [5.7.3] - 2022-02-21

* Fix builds for Flutter 2.10.2
Expand Down
2 changes: 1 addition & 1 deletion LabelStoreMax/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

# WooCommerce App: Label StoreMax

### Label StoreMax - v5.7.3
### Label StoreMax - v5.8.0


[Official WooSignal WooCommerce App](https://woosignal.com)
Expand Down
2 changes: 1 addition & 1 deletion LabelStoreMax/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:4.2.2'
classpath 'com.android.tools.build:gradle:7.0.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.9-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip
8 changes: 4 additions & 4 deletions LabelStoreMax/lib/app/models/checkout_session.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class CheckoutSession {
coupon = null;
}

void saveBillingAddress() async {
saveBillingAddress() async {
CustomerAddress customerAddress =
CheckoutSession.getInstance.billingDetails.billingAddress;

Expand All @@ -66,7 +66,7 @@ class CheckoutSession {
return null;
}

void clearBillingAddress() async =>
clearBillingAddress() async =>
await NyStorage.delete(SharedKey.customerBillingDetails);

saveShippingAddress() async {
Expand All @@ -88,8 +88,8 @@ class CheckoutSession {
return null;
}

void clearShippingAddress() async =>
NyStorage.delete(SharedKey.customerShippingDetails);
clearShippingAddress() async =>
await NyStorage.delete(SharedKey.customerShippingDetails);

Future<String> total({bool withFormat = false, TaxRate taxRate}) async {
double totalCart = parseWcPrice(await Cart.getInstance.getTotal());
Expand Down
9 changes: 9 additions & 0 deletions LabelStoreMax/lib/app/models/customer_address.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class CustomerAddress {
String city;
String postalCode;
String emailAddress;
String phoneNumber;
CustomerCountry customerCountry;

CustomerAddress(
Expand All @@ -26,6 +27,7 @@ class CustomerAddress {
this.city,
this.postalCode,
this.emailAddress,
this.phoneNumber,
this.customerCountry});

void initAddress() {
Expand All @@ -36,6 +38,7 @@ class CustomerAddress {
postalCode = "";
customerCountry = CustomerCountry();
emailAddress = "";
phoneNumber = "";
}

bool hasMissingFields() =>
Expand Down Expand Up @@ -85,6 +88,9 @@ class CustomerAddress {
addressLine = json['address_line'];
city = json['city'];
postalCode = json['postal_code'];
if (json['phone_number'] != null) {
phoneNumber = json['phone_number'];
}
customerCountry = CustomerCountry.fromJson(json['customer_country']);
emailAddress = json['email_address'];
}
Expand All @@ -98,6 +104,9 @@ class CustomerAddress {
data['postal_code'] = postalCode;
data['state'] = customerCountry.state;
data['country'] = customerCountry.name;
if (phoneNumber != null && phoneNumber != "") {
data['phone_number'] = phoneNumber;
}
data['email_address'] = emailAddress;
data['customer_country'] = null;
if (customerCountry != null) {
Expand Down
3 changes: 3 additions & 0 deletions LabelStoreMax/lib/bootstrap/data/order_wc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ Future<OrderWC> buildOrderWC({TaxRate taxRate, bool markPaid = true}) async {
billing.city = billingDetails.billingAddress.city;
billing.postcode = billingDetails.billingAddress.postalCode;
billing.email = billingDetails.billingAddress.emailAddress;
if (billingDetails.billingAddress.phoneNumber != "") {
billing.phone = billingDetails.billingAddress.phoneNumber;
}
if (billingDetails.billingAddress.customerCountry.hasState()) {
billing.state = billingDetails.billingAddress.customerCountry.state.name;
}
Expand Down
45 changes: 29 additions & 16 deletions LabelStoreMax/lib/resources/pages/checkout_details.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class _CheckoutDetailsPageState extends State<CheckoutDetailsPage> {
_txtBillingCity = TextEditingController(),
_txtBillingPostalCode = TextEditingController(),
_txtBillingEmailAddress = TextEditingController(),
_txtBillingPhoneNumber = TextEditingController(),
// shipping
_txtShippingFirstName = TextEditingController(),
_txtShippingLastName = TextEditingController(),
Expand Down Expand Up @@ -74,6 +75,7 @@ class _CheckoutDetailsPageState extends State<CheckoutDetailsPage> {
txtControllerCity: _txtBillingCity,
txtControllerPostalCode: _txtBillingPostalCode,
txtControllerEmailAddress: _txtBillingEmailAddress,
txtControllerPhoneNumber: _txtBillingPhoneNumber,
customerCountry: _billingCountry,
onTapCountry: () => _navigateToSelectCountry(type: "billing"),
);
Expand Down Expand Up @@ -107,6 +109,9 @@ class _CheckoutDetailsPageState extends State<CheckoutDetailsPage> {
CustomerAddress sfCustomerShippingAddress =
await CheckoutSession.getInstance.getShippingAddress();
_setFieldsFromCustomerAddress(sfCustomerShippingAddress, type: "shipping");
setState(() {

});
}

_setFieldsFromCustomerAddress(CustomerAddress customerAddress,
Expand All @@ -122,6 +127,7 @@ class _CheckoutDetailsPageState extends State<CheckoutDetailsPage> {
city: customerAddress.city,
postalCode: customerAddress.postalCode,
emailAddress: customerAddress.emailAddress,
phoneNumber: customerAddress.phoneNumber,
customerCountry: customerAddress.customerCountry,
type: type,
);
Expand All @@ -134,6 +140,7 @@ class _CheckoutDetailsPageState extends State<CheckoutDetailsPage> {
@required String city,
@required String postalCode,
@required String emailAddress,
@required String phoneNumber,
@required CustomerCountry customerCountry,
String type}) {
if (type == "billing") {
Expand All @@ -142,6 +149,7 @@ class _CheckoutDetailsPageState extends State<CheckoutDetailsPage> {
_txtBillingAddressLine.text = addressLine;
_txtBillingCity.text = city;
_txtBillingPostalCode.text = postalCode;
_txtBillingPhoneNumber.text = phoneNumber;
_txtBillingEmailAddress.text = emailAddress;
_billingCountry = customerCountry;
} else if (type == "shipping") {
Expand Down Expand Up @@ -172,20 +180,19 @@ class _CheckoutDetailsPageState extends State<CheckoutDetailsPage> {
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Flexible(
fit: FlexFit.tight,
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.start,
children: [
if (_hasDifferentShippingAddress)
Container(
margin: EdgeInsets.symmetric(vertical: 0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
(_hasDifferentShippingAddress
? Padding(
Padding(
child: Row(
crossAxisAlignment:
CrossAxisAlignment.center,
Expand All @@ -212,14 +219,12 @@ class _CheckoutDetailsPageState extends State<CheckoutDetailsPage> {
].where((e) => e != null).toList(),
),
padding: EdgeInsets.symmetric(vertical: 4),
)
: null),
),
].where((e) => e != null).toList(),
),
height: 60,
),
Flexible(
fit: FlexFit.tight,
Expanded(
child: Container(
decoration: BoxDecoration(
color: ThemeColor.get(context).backgroundContainer,
Expand All @@ -230,7 +235,8 @@ class _CheckoutDetailsPageState extends State<CheckoutDetailsPage> {
: null,
),
padding: EdgeInsets.only(left: 8, right: 8, top: 8),
child: (activeTab ?? tabBillingDetails()),
margin: EdgeInsets.only(top: 8),
child: (activeTab ?? tabBillingDetails())
),
),
],
Expand Down Expand Up @@ -274,7 +280,7 @@ class _CheckoutDetailsPageState extends State<CheckoutDetailsPage> {
),
PrimaryButton(
title: trans("USE DETAILS"),
action: () => _useDetailsTapped(),
action: _useDetailsTapped,
),
],
),
Expand All @@ -286,15 +292,17 @@ class _CheckoutDetailsPageState extends State<CheckoutDetailsPage> {
);
}

_useDetailsTapped() {
_useDetailsTapped() async {
CustomerAddress customerBillingAddress = _setCustomerAddress(
firstName: _txtBillingFirstName.text,
lastName: _txtBillingLastName.text,
addressLine: _txtBillingAddressLine.text,
city: _txtBillingCity.text,
postalCode: _txtBillingPostalCode.text,
phoneNumber: _txtBillingPhoneNumber.text,
emailAddress: _txtBillingEmailAddress.text,
customerCountry: _billingCountry);
customerCountry: _billingCountry,
);

CheckoutSession.getInstance.billingDetails.shippingAddress =
customerBillingAddress;
Expand Down Expand Up @@ -350,11 +358,11 @@ class _CheckoutDetailsPageState extends State<CheckoutDetailsPage> {
}

if (valRememberDetails == true) {
CheckoutSession.getInstance.saveBillingAddress();
CheckoutSession.getInstance.saveShippingAddress();
await CheckoutSession.getInstance.saveBillingAddress();
await CheckoutSession.getInstance.saveShippingAddress();
} else {
CheckoutSession.getInstance.clearBillingAddress();
CheckoutSession.getInstance.clearShippingAddress();
await CheckoutSession.getInstance.clearBillingAddress();
await CheckoutSession.getInstance.clearShippingAddress();
}

CheckoutSession.getInstance.billingDetails.rememberDetails =
Expand All @@ -380,6 +388,7 @@ class _CheckoutDetailsPageState extends State<CheckoutDetailsPage> {
addressLine: "",
city: "",
postalCode: "",
phoneNumber: "",
emailAddress: "",
customerCountry: CustomerCountry());
}
Expand All @@ -393,13 +402,17 @@ class _CheckoutDetailsPageState extends State<CheckoutDetailsPage> {
@required String city,
@required String postalCode,
@required String emailAddress,
String phoneNumber,
@required CustomerCountry customerCountry}) {
CustomerAddress customerShippingAddress = CustomerAddress();
customerShippingAddress.firstName = firstName;
customerShippingAddress.lastName = lastName;
customerShippingAddress.addressLine = addressLine;
customerShippingAddress.city = city;
customerShippingAddress.postalCode = postalCode;
if (phoneNumber != null && phoneNumber != "") {
customerShippingAddress.phoneNumber = phoneNumber;
}
customerShippingAddress.customerCountry = customerCountry;
customerShippingAddress.emailAddress = emailAddress;
return customerShippingAddress;
Expand Down
Loading

0 comments on commit 249f987

Please sign in to comment.