From 4e605bb8c4d34d2345ec1af309ac24a48211c224 Mon Sep 17 00:00:00 2001 From: Anthony Date: Thu, 19 Nov 2020 13:37:47 +0000 Subject: [PATCH] v2.4.0 Option to disable shipping in config --- LabelStoreMax/CHANGELOG.md | 4 + LabelStoreMax/lib/helpers/data/order_wc.dart | 19 +- LabelStoreMax/lib/labelconfig.dart | 4 +- .../lib/pages/checkout_confirmation.dart | 162 ++++++++++-------- LabelStoreMax/pubspec.yaml | 2 +- README.md | 2 +- 6 files changed, 107 insertions(+), 86 deletions(-) diff --git a/LabelStoreMax/CHANGELOG.md b/LabelStoreMax/CHANGELOG.md index 5ca70f7..16658ba 100644 --- a/LabelStoreMax/CHANGELOG.md +++ b/LabelStoreMax/CHANGELOG.md @@ -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 diff --git a/LabelStoreMax/lib/helpers/data/order_wc.dart b/LabelStoreMax/lib/helpers/data/order_wc.dart index 3184bca..647c072 100644 --- a/LabelStoreMax/lib/helpers/data/order_wc.dart +++ b/LabelStoreMax/lib/helpers/data/order_wc.dart @@ -73,6 +73,7 @@ Future 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; @@ -86,14 +87,16 @@ Future buildOrderWC({TaxRate taxRate, bool markPaid = true}) async { orderWC.shipping = shipping; orderWC.shippingLines = []; - Map 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 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) { diff --git a/LabelStoreMax/lib/labelconfig.dart b/LabelStoreMax/lib/labelconfig.dart index 5e47ac2..22200ea 100644 --- a/LabelStoreMax/lib/labelconfig.dart +++ b/LabelStoreMax/lib/labelconfig.dart @@ -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 */ @@ -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 app_locales_supported = [ diff --git a/LabelStoreMax/lib/pages/checkout_confirmation.dart b/LabelStoreMax/lib/pages/checkout_confirmation.dart index b3776fb..8d5859c 100644 --- a/LabelStoreMax/lib/pages/checkout_confirmation.dart +++ b/LabelStoreMax/lib/pages/checkout_confirmation.dart @@ -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'; @@ -208,73 +209,78 @@ class CheckoutConfirmationPageState extends State { ), margin: EdgeInsets.only(top: 5, bottom: 5), child: Column( - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisAlignment: MainAxisAlignment.spaceAround, - children: [ - ((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: [ + ((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( @@ -286,14 +292,18 @@ class CheckoutConfirmationPageState extends State { 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), @@ -322,7 +332,7 @@ class CheckoutConfirmationPageState extends State { Padding( padding: const EdgeInsets.only(top: 15), child: Text( - trans(context, "One moment") + "...", + "${trans(context, "One moment")}...", style: Theme.of(context).primaryTextTheme.subtitle1, ), ) @@ -358,7 +368,8 @@ class CheckoutConfirmationPageState extends State { return; } - if (CheckoutSession.getInstance.shippingType == null) { + if (app_disable_shipping == false && + CheckoutSession.getInstance.shippingType == null) { showEdgeAlertWith( context, title: trans(context, "Oops"), @@ -380,7 +391,8 @@ class CheckoutConfirmationPageState extends State { 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; diff --git a/LabelStoreMax/pubspec.yaml b/LabelStoreMax/pubspec.yaml index 2307c9e..197623e 100644 --- a/LabelStoreMax/pubspec.yaml +++ b/LabelStoreMax/pubspec.yaml @@ -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 # Documentation: https://woosignal.com/docs/app/ios/label-storemax diff --git a/README.md b/README.md index 3205632..143cba0 100644 --- a/README.md +++ b/README.md @@ -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)