Skip to content

Commit

Permalink
v2.4.0 Option to disable shipping in config
Browse files Browse the repository at this point in the history
  • Loading branch information
agordn52 committed Nov 19, 2020
1 parent b2df6c5 commit 4e605bb
Show file tree
Hide file tree
Showing 6 changed files with 107 additions and 86 deletions.
4 changes: 4 additions & 0 deletions LabelStoreMax/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## [2.4.0] - 2020-11-19

* Option to disable shipping in config

## [2.3.0] - 2020-11-18

* Option to set if prices include tax
Expand Down
19 changes: 11 additions & 8 deletions LabelStoreMax/lib/helpers/data/order_wc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ Future<OrderWC> buildOrderWC({TaxRate taxRate, bool markPaid = true}) async {
orderWC.billing = billing;

Shipping shipping = Shipping();

shipping.firstName = billingDetails.shippingAddress.firstName;
shipping.lastName = billingDetails.shippingAddress.lastName;
shipping.address1 = billingDetails.shippingAddress.addressLine;
Expand All @@ -86,14 +87,16 @@ Future<OrderWC> buildOrderWC({TaxRate taxRate, bool markPaid = true}) async {
orderWC.shipping = shipping;

orderWC.shippingLines = [];
Map<String, dynamic> shippingLineFeeObj =
CheckoutSession.getInstance.shippingType.toShippingLineFee();
if (shippingLineFeeObj != null) {
ShippingLines shippingLine = ShippingLines();
shippingLine.methodId = shippingLineFeeObj['method_id'];
shippingLine.methodTitle = shippingLineFeeObj['method_title'];
shippingLine.total = shippingLineFeeObj['total'];
orderWC.shippingLines.add(shippingLine);
if (app_disable_shipping == false) {
Map<String, dynamic> shippingLineFeeObj =
CheckoutSession.getInstance.shippingType.toShippingLineFee();
if (shippingLineFeeObj != null) {
ShippingLines shippingLine = ShippingLines();
shippingLine.methodId = shippingLineFeeObj['method_id'];
shippingLine.methodTitle = shippingLineFeeObj['method_title'];
shippingLine.total = shippingLineFeeObj['total'];
orderWC.shippingLines.add(shippingLine);
}
}

if (taxRate != null) {
Expand Down
4 changes: 3 additions & 1 deletion LabelStoreMax/lib/labelconfig.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import 'dart:ui';
Developer Notes
SUPPORT EMAIL - support@woosignal.com
VERSION - 2.3.0
VERSION - 2.4.0
https://woosignal.com
*/

Expand All @@ -41,6 +41,8 @@ const app_currency_iso = "gbp";

const app_products_prices_include_tax = true;

const app_disable_shipping = false;

const Locale app_locale = Locale('en');

const List<Locale> app_locales_supported = [
Expand Down
162 changes: 87 additions & 75 deletions LabelStoreMax/lib/pages/checkout_confirmation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import 'package:flutter/material.dart';
import 'package:label_storemax/app_payment_methods.dart';
import 'package:label_storemax/app_state_options.dart';
import 'package:label_storemax/helpers/tools.dart';
import 'package:label_storemax/labelconfig.dart';
import 'package:label_storemax/models/cart.dart';
import 'package:label_storemax/models/checkout_session.dart';
import 'package:label_storemax/models/customer_address.dart';
Expand Down Expand Up @@ -208,73 +209,78 @@ class CheckoutConfirmationPageState extends State<CheckoutConfirmationPage> {
),
margin: EdgeInsets.only(top: 5, bottom: 5),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
((CheckoutSession.getInstance.billingDetails != null &&
CheckoutSession.getInstance.billingDetails
.billingAddress !=
null)
? wsCheckoutRow(context,
heading: trans(
context, "Billing/shipping details"),
leadImage: Icon(Icons.home),
leadTitle: (CheckoutSession
.getInstance.billingDetails ==
null ||
CheckoutSession.getInstance
.billingDetails.billingAddress
.hasMissingFields()
? trans(
context, "Billing address is incomplete")
: CheckoutSession.getInstance
.billingDetails.billingAddress
.addressFull()),
action: _actionCheckoutDetails,
showBorderBottom: true)
: wsCheckoutRow(context,
heading: trans(context, "Billing/shipping details"),
leadImage: Icon(Icons.home),
leadTitle: trans(context, "Add billing & shipping details"),
action: _actionCheckoutDetails,
showBorderBottom: true)),
(CheckoutSession.getInstance.paymentType != null
? wsCheckoutRow(context,
heading: trans(context, "Payment method"),
leadImage: Image(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
((CheckoutSession.getInstance.billingDetails != null &&
CheckoutSession.getInstance.billingDetails
.billingAddress !=
null)
? wsCheckoutRow(context,
heading: trans(
context, "Billing/shipping details"),
leadImage: Icon(Icons.home),
leadTitle:
(CheckoutSession.getInstance.billingDetails == null ||
CheckoutSession.getInstance
.billingDetails.billingAddress
.hasMissingFields()
? trans(
context, "Billing address is incomplete")
: CheckoutSession.getInstance
.billingDetails.billingAddress
.addressFull()),
action: _actionCheckoutDetails,
showBorderBottom: true)
: wsCheckoutRow(context,
heading:
trans(context, "Billing/shipping details"),
leadImage: Icon(Icons.home),
leadTitle: trans(context, "Add billing & shipping details"),
action: _actionCheckoutDetails,
showBorderBottom: true)),
(CheckoutSession.getInstance.paymentType != null
? wsCheckoutRow(context,
heading: trans(context, "Payment method"),
leadImage: Image(
image: AssetImage("assets/images/" +
CheckoutSession.getInstance
.paymentType.assetImage),
width: 70),
leadTitle: CheckoutSession
.getInstance.paymentType.desc,
action: _actionPayWith,
showBorderBottom: true)
: wsCheckoutRow(context,
heading: trans(context, "Pay with"),
leadImage: Icon(Icons.payment),
leadTitle:
trans(context, "Select a payment method"),
action: _actionPayWith,
showBorderBottom: true)),
(CheckoutSession.getInstance.shippingType != null
? wsCheckoutRow(context,
heading: trans(context, "Shipping selected"),
leadImage: Icon(Icons.local_shipping),
leadTitle: CheckoutSession
.getInstance.shippingType
.getTitle(),
action: _actionSelectShipping)
: wsCheckoutRow(
context,
heading: trans(context, "Select shipping"),
leadImage: Icon(Icons.local_shipping),
leadTitle: trans(
context, "Select a shipping option"),
action: _actionSelectShipping,
)),
],
),
width: 70,
),
leadTitle: CheckoutSession
.getInstance.paymentType.desc,
action: _actionPayWith,
showBorderBottom: true)
: wsCheckoutRow(context,
heading: trans(context, "Pay with"),
leadImage: Icon(Icons.payment),
leadTitle: trans(
context, "Select a payment method"),
action: _actionPayWith,
showBorderBottom: true)),
app_disable_shipping == true
? null
: (CheckoutSession.getInstance.shippingType !=
null
? wsCheckoutRow(context,
heading:
trans(context, "Shipping selected"),
leadImage: Icon(Icons.local_shipping),
leadTitle: CheckoutSession
.getInstance.shippingType
.getTitle(),
action: _actionSelectShipping)
: wsCheckoutRow(
context,
heading:
trans(context, "Select shipping"),
leadImage: Icon(Icons.local_shipping),
leadTitle: trans(context,
"Select a shipping option"),
action: _actionSelectShipping,
)),
].where((e) => e != null).toList()),
),
),
Column(
Expand All @@ -286,14 +292,18 @@ class CheckoutConfirmationPageState extends State<CheckoutConfirmationPage> {
thickness: 1,
),
wsCheckoutSubtotalWidgetFB(
title: trans(context, "Subtotal")),
widgetCheckoutMeta(context,
title: trans(context, "Shipping fee"),
amount:
CheckoutSession.getInstance.shippingType == null
? trans(context, "Select shipping")
: CheckoutSession.getInstance.shippingType
.getTotal(withFormatting: true)),
title: trans(context, "Subtotal"),
),
app_disable_shipping == true
? null
: widgetCheckoutMeta(context,
title: trans(context, "Shipping fee"),
amount:
CheckoutSession.getInstance.shippingType ==
null
? trans(context, "Select shipping")
: CheckoutSession.getInstance.shippingType
.getTotal(withFormatting: true)),
(_taxRate != null
? wsCheckoutTaxAmountWidgetFB(taxRate: _taxRate)
: null),
Expand Down Expand Up @@ -322,7 +332,7 @@ class CheckoutConfirmationPageState extends State<CheckoutConfirmationPage> {
Padding(
padding: const EdgeInsets.only(top: 15),
child: Text(
trans(context, "One moment") + "...",
"${trans(context, "One moment")}...",
style: Theme.of(context).primaryTextTheme.subtitle1,
),
)
Expand Down Expand Up @@ -358,7 +368,8 @@ class CheckoutConfirmationPageState extends State<CheckoutConfirmationPage> {
return;
}

if (CheckoutSession.getInstance.shippingType == null) {
if (app_disable_shipping == false &&
CheckoutSession.getInstance.shippingType == null) {
showEdgeAlertWith(
context,
title: trans(context, "Oops"),
Expand All @@ -380,7 +391,8 @@ class CheckoutConfirmationPageState extends State<CheckoutConfirmationPage> {
return;
}

if (CheckoutSession.getInstance.shippingType.minimumValue != null) {
if (app_disable_shipping == false &&
CheckoutSession.getInstance.shippingType.minimumValue != null) {
String total = await Cart.getInstance.getTotal();
if (total == null) {
return;
Expand Down
2 changes: 1 addition & 1 deletion LabelStoreMax/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Official WooSignal App Template for WooCommerce

# Label StoreMax
# Version 2.3.0
# Version 2.4.0
# Homepage: https://woosignal.com
# Author: Anthony Gordon <agordon@woosignal.com>
# Documentation: https://woosignal.com/docs/app/ios/label-storemax
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

# WooCommerce App: Label StoreMax

### Label StoreMax - v2.3.0
### Label StoreMax - v2.4.0


[Official WooSignal WooCommerce App](https://woosignal.com)
Expand Down

0 comments on commit 4e605bb

Please sign in to comment.