Skip to content

Conversation

@AnirudhBhat
Copy link
Contributor

@AnirudhBhat AnirudhBhat commented May 22, 2023

Closes: #9073

Description

This PR handles failure when

  1. The barcode scanning fails
  2. The product search by SKU fails

We show a Snackbar with a "retry" action in both cases. Clicking on the "retry" action will trigger the scanning process.

More context: pecCkj-GT-p2

Testing instructions

Order listing screen

  1. Navigate to the Orders tab
  2. Click on the barcode icon present on the toolbar
  3. Scan the barcode (Make sure to generate the barcode with an invalid SKU not present in your store - example: https://barcode.tec-it.com/en/?data=invalid_sku)
  4. Ensure you see the snack bar
  5. Ensure the retry action starts the scanning process again

Order detail screen

  1. Navigate to the Order details screen (orders -> "+")
  2. Click on the barcode icon present under the products section
  3. Scan the barcode (Make sure to generate the barcode with an invalid SKU not present in your store - example: https://barcode.tec-it.com/en/?data=invalid_sku)
  4. Ensure you see the snack bar
  5. Ensure the retry action starts the scanning process again

Images/gif

screen-20230522-154828.mp4
  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

…le message when the product search by SKU fails.
@wpmobilebot
Copy link
Collaborator

wpmobilebot commented May 22, 2023

You can test the changes on this Pull Request by downloading an installable build, or scanning this QR code:

@codecov-commenter
Copy link

codecov-commenter commented May 22, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.11 🎉

Comparison is base (debe810) 43.48% compared to head (b6dc535) 43.59%.

Additional details and impacted files
@@             Coverage Diff              @@
##              trunk    #9082      +/-   ##
============================================
+ Coverage     43.48%   43.59%   +0.11%     
- Complexity     4032     4094      +62     
============================================
  Files           833      834       +1     
  Lines         43900    43985      +85     
  Branches       5734     5763      +29     
============================================
+ Hits          19088    19176      +88     
  Misses        23137    23137              
+ Partials       1675     1672       -3     
Impacted Files Coverage Δ
...commerce/android/ui/orders/creation/CodeScanner.kt 100.00% <100.00%> (ø)
...ui/orders/creation/GoogleCodeScannerErrorMapper.kt 100.00% <100.00%> (ø)
...oid/ui/orders/creation/OrderCreateEditViewModel.kt 86.99% <100.00%> (+1.14%) ⬆️

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

}
}

data class OnBarcodeScanningFailed(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both these event models might look similar in code but their behavior might change in the near future. Also, the code can be confusing to understand when we merge both into one. Let me know your thoughts.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd go with 1 event at the beggining, e.g. OnAddingProductViaScaningFailed (we don't only support barcodes but other types of encoding of the data) and will pass 2 different messages there: Scanning failed with error: %s and Unable to find product with SKU: %s. That should give more information to a user

@AnirudhBhat AnirudhBhat requested a review from kidinov May 22, 2023 12:41
@AnirudhBhat AnirudhBhat added the feature: mobile payments Related to mobile payments / card present payments / Woo Payments. label May 22, 2023
@AnirudhBhat AnirudhBhat added this to the 13.8 milestone May 22, 2023
@AnirudhBhat AnirudhBhat marked this pull request as ready for review May 22, 2023 12:42
@kidinov kidinov self-assigned this May 23, 2023
@AnirudhBhat AnirudhBhat marked this pull request as ready for review May 23, 2023 08:23
Copy link
Contributor

@kidinov kidinov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left a few comments, please take a look

private fun sendBarcodeScanningFailedEvent(error: Throwable?) {
triggerEvent(
OnBarcodeScanningFailed(
error,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error property is never used in both events in the production code? In OnBarcodeScanningFailed and OnProductSearchBySKUFailed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strange. I had already removed the error property from both events. In the latest file change, it's not shown.

}
}

data class OnBarcodeScanningFailed(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd go with 1 event at the beggining, e.g. OnAddingProductViaScaningFailed (we don't only support barcodes but other types of encoding of the data) and will pass 2 different messages there: Scanning failed with error: %s and Unable to find product with SKU: %s. That should give more information to a user

@peril-woocommerce
Copy link

peril-woocommerce bot commented May 23, 2023

Warnings
⚠️ This PR is assigned to a milestone which is closing in less than 2 days Please, make sure to get it merged by then or assign it to a later expiring milestone

Generated by 🚫 dangerJS

…and merge them into one event OnAddingProductViaScanningFailed
private fun sendAddingProductsViaScanningFailedEvent() {
triggerEvent(
OnAddingProductViaScanningFailed(
string.order_creation_barcode_scanning_unable_to_add_product
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now you show the same text Product not found. Unable to add to new order for both cases - when scanning failed (including when the scanning is not available at all) and when we could not find a product by SKU

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a separate message for both failure events here: aaecceb

Right now, the messages are static without much information on what went wrong. This will be taken on priority and will be discussed with Ann and should be out by next week after the initial release.

Copy link
Contributor

@kidinov kidinov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left a comment regarding the text currently used for error indication - it may be missliding

Copy link
Contributor

@kidinov kidinov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left a comment regarding the text currently used for error indication - it may be missliding

@kidinov kidinov self-requested a review May 24, 2023 08:13
Copy link
Contributor

@kidinov kidinov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@kidinov kidinov enabled auto-merge May 24, 2023 08:14
@kidinov kidinov merged commit a8d8116 into trunk May 24, 2023
@kidinov kidinov deleted the issue/9073-handle-error-case-barcode-scanning branch May 24, 2023 08:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature: mobile payments Related to mobile payments / card present payments / Woo Payments.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Handle error case when the barcode scanning fails

5 participants