Skip to content

[Shipping labels] Improve the error message for empty shipping rates list #14433

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 11 commits into
base: trunk
Choose a base branch
from

Conversation

irfano
Copy link
Contributor

@irfano irfano commented Aug 5, 2025

Description

This adds a specific error message for the case when no shipping rates are available.

The error message

When hazmat is not selected

We couldn't find a shipping service for the combination of the selected package and the total shipment weight. Please adjust your input and try again.

When hazmat is selected

We couldn't find a shipping service for the combination of the selected HAZMAT category, the selected package and the total shipment weight. Please adjust your input and try again.

Steps to reproduce

  1. Go to Orders.
  2. Select an order that is eligible for creating shipping labels.
  3. Tap Create shipping labels button.
  4. Select a package.
  5. Type 9999 to weight field to the error message.
  6. Tap "Are you shipping dangerous goods or hazardous materials?"
  7. Check "Contains hazardous materials.
  8. Tap Select Category button.
  9. Select an item.

The tests that have been performed

Steps above

Images/gif

Before After
Screenshot_20250805_220610 after1
Screenshot_20250805_220629 after2
  • I have considered if this change warrants release notes and have added them to RELEASE-NOTES.txt if necessary. Use the "[Internal]" label for non-user-facing changes.

irfano added 6 commits August 5, 2025 21:36
New string resources are added to inform users when no shipping services are found for their selected package and shipment weight, including a specific message for shipments containing hazardous materials.
A new exception class `NoAvailableRatesException` is added to handle cases where no shipping rates are available. This exception includes a string resource ID for a user-friendly message.
The `ShippingRatesSection` composable is updated to display error messages from the `ShippingRatesState.Error` state, rather than a generic, hardcoded string.
This allows for more specific error messages to be shown to the user.
The `ErrorMessageWithButton` composable now has a 16.dp padding.
@irfano irfano added this to the 23.0 milestone Aug 5, 2025
@irfano irfano added feature: shipping labels Related to creating, ordering, or printing shipping labels. Enhancement labels Aug 5, 2025
@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Aug 5, 2025

📲 You can test the changes from this Pull Request in WooCommerce-Wear Android by scanning the QR code below to install the corresponding build.
App Name WooCommerce-Wear Android
Platform⌚️ Wear OS
FlavorJalapeno
Build TypeDebug
Commitdc9c6ba
Direct Downloadwoocommerce-wear-prototype-build-pr14433-dc9c6ba.apk

@irfano irfano marked this pull request as ready for review August 5, 2025 19:17
val errorMessage = if (exception is NoAvailableRatesException) {
exception.messageResId
} else {
trackShippingRatesLoading(isSuccess = false, error = exception.message)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

trackShippingRatesLoading() was being triggered when the endpoint returned empty rates, but an empty rates case is not actually an error. So, I removed the tracking for it.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure about this. I agree empty rates is not an error but we might want to track it anyway. We could add something like:

            analyticsTracker.track(AnalyticsEvent.WCS_RATE_SELECTION_STEP, mapOf(KEY_STATE to "loading_success_empty_rates"))

Wdyt?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I want to include @itsmeichigo in the discussion. Do you track empty rates on iOS?

@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Aug 5, 2025

📲 You can test the changes from this Pull Request in WooCommerce Android by scanning the QR code below to install the corresponding build.

App Name WooCommerce Android
Platform📱 Mobile
FlavorJalapeno
Build TypeDebug
Commitdc9c6ba
Direct Downloadwoocommerce-prototype-build-pr14433-dc9c6ba.apk

@codecov-commenter
Copy link

codecov-commenter commented Aug 5, 2025

Codecov Report

❌ Patch coverage is 46.66667% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 38.01%. Comparing base (9c0dbf9) to head (dc9c6ba).

Files with missing lines Patch % Lines
...hippinglabels/WooShippingLabelCreationViewModel.kt 66.66% 1 Missing and 1 partial ⚠️
...bels/packages/components/ErrorMessageWithButton.kt 0.00% 2 Missing ⚠️
...wooshippinglabels/rates/domain/GetShippingRates.kt 60.00% 1 Missing and 1 partial ⚠️
...wooshippinglabels/rates/ui/ShippingRatesSection.kt 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##              trunk   #14433   +/-   ##
=========================================
  Coverage     38.01%   38.01%           
  Complexity     9229     9229           
=========================================
  Files          1993     1993           
  Lines        112506   112514    +8     
  Branches      14843    14845    +2     
=========================================
+ Hits          42771    42776    +5     
- Misses        65839    65840    +1     
- Partials       3896     3898    +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@irfano irfano modified the milestones: 23.0, 23.1 Aug 8, 2025
@JorgeMucientes JorgeMucientes self-assigned this Aug 11, 2025
Copy link
Contributor

@JorgeMucientes JorgeMucientes left a comment

Choose a reason for hiding this comment

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

Hey @irfano Changes work well and code looks good. I just left a minor suggestion but nothing blocking. Let me know your thought :)

val errorMessage = if (exception is NoAvailableRatesException) {
exception.messageResId
} else {
trackShippingRatesLoading(isSuccess = false, error = exception.message)
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure about this. I agree empty rates is not an error but we might want to track it anyway. We could add something like:

            analyticsTracker.track(AnalyticsEvent.WCS_RATE_SELECTION_STEP, mapOf(KEY_STATE to "loading_success_empty_rates"))

Wdyt?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement feature: shipping labels Related to creating, ordering, or printing shipping labels.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants