Skip to content

Commit 5284e8f

Browse files
committed
fixed a bug that causes checkout limit messages to not appear when pressing the checkout button
1 parent e3a1911 commit 5284e8f

File tree

4 files changed

+25
-4
lines changed

4 files changed

+25
-4
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
# Changelog
22
All notable changes to this project will be documented in this file.
33

4+
## [0.14.4]
5+
6+
### Fixed
7+
- Fixed a bug that caused the checkout limit message to not appear when checking out im some cases
8+
49
## [0.14.3]
510

611
### Changes

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ allprojects {
2323
}
2424

2525
project.ext {
26-
sdkVersion='0.14.3'
26+
sdkVersion='0.14.4'
2727
versionCode=1
2828

2929
compileSdkVersion=28

core/src/main/java/io/snabble/sdk/ShoppingCart.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,14 @@ public int getTotalQuantity() {
288288
return sum;
289289
}
290290

291+
public boolean hasReachedMaxCheckoutLimit() {
292+
return hasRaisedMaxCheckoutLimit;
293+
}
294+
295+
public boolean hasReachedMaxOnlinePaymentLimit() {
296+
return hasRaisedMaxOnlinePaymentLimit;
297+
}
298+
291299
private void updateTimestamp() {
292300
lastModificationTime = System.currentTimeMillis();
293301
}

ui/src/main/java/io/snabble/sdk/ui/cart/ShoppingCartView.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ public ShoppingCartView(Context context, AttributeSet attrs, int defStyleAttr) {
123123
private void inflateView(Context context, AttributeSet attrs) {
124124
inflate(getContext(), R.layout.snabble_view_shopping_cart, this);
125125
picasso = Picasso.with(getContext());
126-
Project project = SnabbleUI.getProject();
126+
final Project project = SnabbleUI.getProject();
127127

128128
if (cart != null) {
129129
cart.removeListener(shoppingCartListener);
@@ -178,8 +178,16 @@ public boolean onKey(DialogInterface dialogInterface, int i, KeyEvent keyEvent)
178178
pay.setOnClickListener(new OneShotClickListener() {
179179
@Override
180180
public void click() {
181-
checkout.checkout();
182-
Telemetry.event(Telemetry.Event.ClickCheckout);
181+
if (cart.hasReachedMaxCheckoutLimit()) {
182+
Project project = SnabbleUI.getProject();
183+
String message = getResources().getString(R.string.Snabble_limitsAlert_checkoutNotAvailable,
184+
project.getPriceFormatter().format(project.getMaxCheckoutLimit()));
185+
snackbar = UIUtils.snackbar(coordinatorLayout, message, UIUtils.SNACKBAR_LENGTH_VERY_LONG);
186+
snackbar.show();
187+
} else {
188+
checkout.checkout();
189+
Telemetry.event(Telemetry.Event.ClickCheckout);
190+
}
183191
}
184192
});
185193

0 commit comments

Comments
 (0)