Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Display the link to add the shipping address when shipping address is not available #8141

Merged
merged 34 commits into from
Mar 22, 2023

Conversation

tarunvijwani
Copy link

@tarunvijwani tarunvijwani commented Jan 10, 2023

With this PR, we display a link to add the shipping address in the shipping calculator on the cart page when the shipping address is unavailable. We're also hiding the option to change the shipping address when default shipping rates are defined.

Fixes #8027 and #7730

Changes in the PR

  • Replaced hardcoded notices with text for Cart and Checkout block.
  • Fixed the shipping placeholder for the Checkout block when no shipping rates are available.
  • Created a function in base/utils to format Shipping address.
  • Removed the condition to check the default customer address. Display the "Add shipping address" link only when no address is available.
  • Hide shipping calculator if default shipping is defined.

Accessibility

Screenshots

Before After
image image

Testing

Automated Tests

  • Changes in this PR are covered by Automated Tests.
    • Unit tests
    • E2E tests

User Facing Testing

case 1 (With no default shipping rates)

image

  1. Check out this branch.
  2. Go to the WooCommerce settings page: wp-admin/admin.php?page=wc-settings.
  3. Change 'Default customer location' to No location by default.
  4. Remove any default(fallback) shipping rates.
  5. Open your site in a private session(incognito mode).
  6. Add some products to the cart.
  7. Go to the cart page, and confirm the "Add an address for shipping rates" link is present in the shipping calculator.
  8. Click on the link, and confirm it is working as expected.
  9. Open your site in a regular session where you're already logged in and have placed an order before.
  10. Add some products to the cart.
  11. Go to the cart page, confirm the shipping address, and "change address" link present in the shipping calculator.
  12. Click on the link, and confirm it is working as expected.

case 2(With default shipping rates)

image

  1. Check out this branch.
  2. Go to the WooCommerce settings page: wp-admin/admin.php?page=wc-settings.
  3. Change 'Default customer location' to No location by default.
  4. Add any default(fallback) shipping rates.
  5. Open your site in a private session(incognito mode).
  6. Add some products to the cart.
  7. Go to the cart page, and confirm the shipping calculator is hidden and default shipping rates are visible
  8. Open your site in a regular session where you're already logged in and have placed an order before.
  9. Add some products to the cart.
  10. Go to the cart page, confirm the shipping address, and "change address" link present in the shipping calculator.
  11. Click on the link, and confirm it is working as expected.

case 3(Error Notice)

  1. Check out this branch.
  2. Go to the WooCommerce settings page: wp-admin/admin.php?page=wc-settings.
  3. Change 'Default customer location' to No location by default.
  4. Remove any default(fallback) shipping rates.
  5. Open your site in a private session(incognito mode).
  6. Add some products to the cart.
  7. Go to the cart page, and confirm the "Add an address for shipping rates" link is present in the shipping calculator.
  8. Click on the link, and change the address to a location where shipping rates are unavailable.
  9. Confirm that There are no shipping options available. Please check your shipping address. error is visible in the text form.
  10. Proceed to the Checkout block page, and confirm the There are no shipping options available. Please check your shipping address error is visible in the text form under Shipping options.
  • Do not include in the Testing Notes

WooCommerce Visibility

  • WooCommerce Core
  • Feature plugin
  • Experimental

Changelog

Display the link to add the shipping address when the shipping address is not available.

@tarunvijwani tarunvijwani self-assigned this Jan 10, 2023
@tarunvijwani tarunvijwani added type: enhancement The issue is a request for an enhancement. block: cart Issues related to the cart block. focus: settings Issues related to managing settings (including wc-settings). labels Jan 10, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Jan 10, 2023

The release ZIP for this PR is accessible via:

https://wcblocks.wpcomstaging.com/wp-content/uploads/woocommerce-gutenberg-products-block-8141.zip

Script Dependencies Report

There is no changed script dependency between this branch and trunk.

This comment was automatically generated by the ./github/compare-assets action.

TypeScript Errors Report

  • Files with errors: 479
  • Total errors: 2296

⚠️ ⚠️ This PR introduces new TS errors on 2 files:

assets/js/base/components/cart-checkout/totals/shipping/test/index.tsx

assets/js/base/utils/address.ts

comments-aggregator

@tarunvijwani tarunvijwani marked this pull request as ready for review January 10, 2023 07:39
@woocommercebot woocommercebot requested review from a team and mikejolley and removed request for a team January 10, 2023 07:39
@github-actions
Copy link
Contributor

github-actions bot commented Jan 10, 2023

Size Change: -95 B (0%)

Total Size: 1.06 MB

Filename Size Change
build/active-filters-frontend.js 7.97 kB +2 B (0%)
build/active-filters-wrapper-frontend.js 5.99 kB -1 B (0%)
build/active-filters.js 7.47 kB +3 B (0%)
build/all-products-frontend.js 11.8 kB +170 B (+1%)
build/all-products.js 36.8 kB +188 B (+1%)
build/all-reviews.js 7.66 kB +2 B (0%)
build/attribute-filter-frontend.js 22.4 kB +6 B (0%)
build/attribute-filter-wrapper--stock-filter-wrapper-frontend.js 3.35 kB +1 B (0%)
build/attribute-filter-wrapper-frontend.js 4.5 kB -2 B (0%)
build/blocks-checkout.js 43.9 kB -1 B (0%)
build/cart-blocks/cart-accepted-payment-methods-frontend.js 1.38 kB +2 B (0%)
build/cart-blocks/cart-cross-sells-products-frontend.js 9.76 kB -2 B (0%)
build/cart-blocks/cart-express-payment-frontend.js 720 B +1 B (0%)
build/cart-blocks/cart-line-items--mini-cart-contents-block/products-table-frontend.js 5.36 kB +1 B (0%)
build/cart-blocks/cart-line-items-frontend.js 1.06 kB -2 B (0%)
build/cart-blocks/empty-cart-frontend.js 345 B -1 B (0%)
build/cart-blocks/order-summary-discount-frontend.js 2.12 kB -2 B (0%)
build/cart-blocks/order-summary-heading-frontend.js 456 B -1 B (0%)
build/cart-blocks/order-summary-shipping-frontend.js 10.7 kB -469 B (-4%)
build/cart-blocks/order-summary-taxes-frontend.js 434 B +1 B (0%)
build/cart-blocks/proceed-to-checkout-frontend.js 1.33 kB +3 B (0%)
build/cart-frontend.js 29.3 kB +139 B (0%)
build/cart.js 48.2 kB +166 B (0%)
build/checkout-blocks/actions-frontend.js 1.84 kB -3 B (0%)
build/checkout-blocks/billing-address-frontend.js 4.19 kB -1 B (0%)
build/checkout-blocks/contact-information-frontend.js 2.05 kB +1 B (0%)
build/checkout-blocks/order-note-frontend.js 1.14 kB -1 B (0%)
build/checkout-blocks/order-summary-cart-items-frontend.js 3.68 kB +2 B (0%)
build/checkout-blocks/order-summary-coupon-form-frontend.js 1.78 kB -1 B (0%)
build/checkout-blocks/order-summary-discount-frontend.js 2.29 kB -2 B (0%)
build/checkout-blocks/order-summary-shipping-frontend.js 10.8 kB -465 B (-4%)
build/checkout-blocks/payment-frontend.js 8.39 kB -38 B (0%)
build/checkout-blocks/pickup-options-frontend.js 4.04 kB +3 B (0%)
build/checkout-blocks/shipping-address-frontend.js 4.14 kB +3 B (0%)
build/checkout-blocks/shipping-method-frontend.js 2.61 kB -1 B (0%)
build/checkout-blocks/shipping-methods-frontend.js 4.82 kB -441 B (-8%)
build/checkout-blocks/terms-frontend.js 1.56 kB +2 B (0%)
build/checkout-frontend.js 30.9 kB +139 B (0%)
build/checkout.js 45.7 kB +160 B (0%)
build/featured-category.js 14 kB -1 B (0%)
build/featured-product.js 14.4 kB -4 B (0%)
build/handpicked-products.js 7.9 kB -1 B (0%)
build/mini-cart-component-frontend.js 28 kB +177 B (+1%)
build/mini-cart-contents-block/empty-cart-frontend.js 360 B +1 B (0%)
build/mini-cart-contents.js 17 kB +129 B (+1%)
build/price-filter-frontend.js 13.9 kB +3 B (0%)
build/price-filter-wrapper-frontend.js 6.99 kB +3 B (0%)
build/price-filter.js 8.39 kB +3 B (0%)
build/product-add-to-cart-frontend.js 6.43 kB +1 B (0%)
build/product-best-sellers.js 8.25 kB -2 B (0%)
build/product-button-frontend.js 1.98 kB +1 B (0%)
build/product-category.js 9.24 kB -2 B (0%)
build/product-image-frontend.js 1.83 kB -3 B (0%)
build/product-on-sale.js 8.58 kB -2 B (0%)
build/product-query.js 11 kB +1 B (0%)
build/product-summary-frontend.js 1.35 kB +2 B (0%)
build/product-tag.js 8.73 kB -3 B (0%)
build/product-title-frontend.js 1.41 kB +4 B (0%)
build/product-top-rated.js 8.49 kB -1 B (0%)
build/products-by-attribute.js 9.57 kB -1 B (0%)
build/rating-filter-frontend.js 20.8 kB +5 B (0%)
build/rating-filter-wrapper-frontend.js 5.61 kB +1 B (0%)
build/rating-filter.js 7.42 kB +2 B (0%)
build/reviews-by-category.js 11.9 kB +1 B (0%)
build/reviews-by-product.js 13 kB +2 B (0%)
build/stock-filter-frontend.js 21 kB +5 B (0%)
build/stock-filter-wrapper-frontend.js 3.15 kB -2 B (0%)
build/stock-filter.js 8.13 kB +1 B (0%)
build/vendors--attribute-filter-wrapper--cart-blocks/cart-cross-sells-products--cart-blocks/order-summary--82e4ed06-frontend.js 0 B -6.86 kB (removed) 🏆
build/vendors--cart-blocks/cart-cross-sells-products--cart-blocks/order-summary-shipping--checkout-blocks--18f9376a-frontend.js 19.4 kB +2 B (0%)
build/vendors--checkout-blocks/shipping-method-frontend.js 12 kB +1 B (0%)
build/wc-blocks-data.js 21.8 kB -1 B (0%)
build/wc-blocks-shared-hocs.js 1.73 kB -1 B (0%)
build/wc-blocks-style-rtl.css 26.9 kB +10 B (0%)
build/wc-blocks-style.css 26.8 kB +10 B (0%)
build/wc-blocks-vendors.js 64.2 kB +3 B (0%)
build/vendors--attribute-filter-wrapper--cart-blocks/cart-cross-sells-products--cart-blocks/order-summary--ef6753df-frontend.js 6.86 kB +6.86 kB (new file) 🆕
ℹ️ View Unchanged
Filename Size
build/attribute-filter.js 13.2 kB
build/breadcrumbs.js 2.05 kB
build/cart-blocks/cart-cross-sells-frontend.js 253 B
build/cart-blocks/cart-express-payment--checkout-blocks/express-payment-frontend.js 5.19 kB
build/cart-blocks/cart-items-frontend.js 301 B
build/cart-blocks/cart-order-summary-frontend.js 1.24 kB
build/cart-blocks/cart-totals-frontend.js 307 B
build/cart-blocks/filled-cart-frontend.js 655 B
build/cart-blocks/order-summary-coupon-form-frontend.js 1.62 kB
build/cart-blocks/order-summary-fee-frontend.js 274 B
build/cart-blocks/order-summary-subtotal-frontend.js 275 B
build/catalog-sorting.js 1.7 kB
build/checkout-blocks/express-payment-frontend.js 1.13 kB
build/checkout-blocks/fields-frontend.js 331 B
build/checkout-blocks/order-summary-fee-frontend.js 277 B
build/checkout-blocks/order-summary-frontend.js 1.24 kB
build/checkout-blocks/order-summary-subtotal-frontend.js 275 B
build/checkout-blocks/order-summary-taxes-frontend.js 434 B
build/checkout-blocks/totals-frontend.js 310 B
build/customer-account.js 3.17 kB
build/filter-wrapper-frontend.js 14.1 kB
build/filter-wrapper.js 2.39 kB
build/general-style-rtl.css 1.31 kB
build/general-style.css 1.31 kB
build/legacy-template.js 5.32 kB
build/mini-cart-contents-block/filled-cart-frontend.js 268 B
build/mini-cart-contents-block/footer-frontend.js 2.86 kB
build/mini-cart-contents-block/items-frontend.js 237 B
build/mini-cart-contents-block/products-table-frontend.js 589 B
build/mini-cart-contents-block/shopping-button-frontend.js 572 B
build/mini-cart-contents-block/title-frontend.js 368 B
build/mini-cart-frontend.js 2.02 kB
build/mini-cart.js 4.49 kB
build/price-format.js 1.19 kB
build/product-add-to-cart.js 178 B
build/product-categories.js 2.36 kB
build/product-image.js 178 B
build/product-new.js 8.25 kB
build/product-price-frontend.js 2.14 kB
build/product-rating-frontend.js 1.4 kB
build/product-results-count.js 1.66 kB
build/product-sale-badge-frontend.js 1.04 kB
build/product-search.js 2.63 kB
build/product-sku-frontend.js 453 B
build/product-stock-indicator-frontend.js 1.07 kB
build/product-title.js 178 B
build/reviews-frontend.js 7.11 kB
build/store-notices.js 1.69 kB
build/vendors--attribute-filter-wrapper--rating-filter-wrapper--stock-filter-wrapper-frontend.js 7.69 kB
build/vendors--cart-blocks/cart-cross-sells-products--cart-blocks/cart-line-items--cart-blocks/cart-order--3c5fe802-frontend.js 5.26 kB
build/vendors--cart-blocks/cart-cross-sells-products--product-add-to-cart-frontend.js 7.25 kB
build/vendors--cart-blocks/cart-line-items--checkout-blocks/order-summary-cart-items--mini-cart-contents---233ab542-frontend.js 3.14 kB
build/vendors--cart-blocks/order-summary-shipping--checkout-blocks/order-summary-shipping--checkout-block--24d3fc0c-frontend.js 8.24 kB
build/vendors--checkout-blocks/billing-address--checkout-blocks/shipping-address-frontend.js 5.44 kB
build/wc-blocks-editor-style-rtl.css 5.78 kB
build/wc-blocks-editor-style.css 5.78 kB
build/wc-blocks-google-analytics.js 1.56 kB
build/wc-blocks-middleware.js 930 B
build/wc-blocks-registry.js 3.15 kB
build/wc-blocks-shared-context.js 1.52 kB
build/wc-blocks-vendors-style-rtl.css 1.96 kB
build/wc-blocks-vendors-style.css 1.96 kB
build/wc-blocks.js 2.63 kB
build/wc-payment-method-bacs.js 816 B
build/wc-payment-method-cheque.js 811 B
build/wc-payment-method-cod.js 909 B
build/wc-payment-method-paypal.js 837 B
build/wc-settings.js 2.6 kB
build/wc-shipping-method-pickup-location.js 29.9 kB
build/woo-directives-runtime.js 2.73 kB
build/woo-directives-vendors.js 7.91 kB

compressed-size-action

@mikejolley
Copy link
Member

Before looking at the code, is it not strange that the text here states "Add an address for shipping rates", but still displays shipping rates below? It seems like this link should only change if there are no rates displayed. Unless of course the link text is made slightly more generic so it fits both cases.

@tarunvijwani
Copy link
Author

Before looking at the code, is it not strange that the text here states "Add an address for shipping rates", but still displays shipping rates below? It seems like this link should only change if there are no rates displayed. Unless of course the link text is made slightly more generic so it fits both cases.

That's a great point. I think we can change the text to something like "Add an address to get the exact shipping rates"

@elizaan36 @ralucaStan I'd love to hear your thoughts.

Copy link
Member

@mikejolley mikejolley left a comment

Choose a reason for hiding this comment

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

The logic makes sense, just a question on reuse and then perhaps a change to the text if needed.

src/BlockTypes/Cart.php Outdated Show resolved Hide resolved

const formattedLocation = formatShippingAddress( shippingAddress );
const label =
! hasDefaultCustomerAddress && ! formattedLocation
Copy link
Author

Choose a reason for hiding this comment

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

@mikejolley Do you think we should remove hasDefaultCustomerAddress check as well? I think formatLocation null check is enough to determine whether we have the address or not to change the label, irrespective of the user's setting in WC. Let me know your thoughts.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah that makes sense, I'm assuming that formatted location logic needs the basics (state, country, city) or will null. If thats the case, yes remove it.

@elizaan36
Copy link

hey @tarunvijwani @mikejolley

It's my understanding that the text "Add an address for shipping rates" would only appear when there are no rates shown. What's the use case where the link would show alongside rates?

@tarunvijwani tarunvijwani marked this pull request as draft January 17, 2023 06:18
@tarunvijwani
Copy link
Author

It's my understanding that the text "Add an address for shipping rates" would only appear when there are no rates shown. What's the use case where the link would show alongside rates?

@elizaan36 If the merchant has defined the default shipping rates that are applicable for every location, then it will show the rates. If the customer adds their address, the shipping rates will change according to their location. The Cart Shortcode page also follows the same approach.

Screen.Recording.2023-01-19.at.12.39.36.PM.mov

However, if the merchant has not defined the default shipping rates, then it will display the error(We're adding the changes of #8130 to this PR to keep the text consistent)

Screen.Recording.2023-01-19.at.12.42.53.PM.mov

@elizaan36
Copy link

@elizaan36 If the merchant has defined the default shipping rates that are applicable for every location, then it will show the rates.

I imagine the merchant's intention would be to offer the flat rate and turn off the shipping calculator in that case. So I'd say if the merchant has chosen a flat rate for all locations, the link shouldn't appear.

It's quite confusing for the shopper to see "Flat rate" or "Free shipping" with a link that might change these rates. What do you think?

However, if the merchant has not defined the default shipping rates, then it will display the error(We're adding the changes of #8130 to this PR to keep the text consistent)

Nice, this makes sense and glad we can align the experience there!

@tarunvijwani
Copy link
Author

I imagine the merchant's intention would be to offer the flat rate and turn off the shipping calculator in that case. So I'd say if the merchant has chosen a flat rate for all locations, the link shouldn't appear.
It's quite confusing for the shopper to see "Flat rate" or "Free shipping" with a link that might change these rates. What do you think?

Yes, that makes perfect sense! I'll incorporate the changes. Thank you!

- Replace hardcoded notices with text for Cart and Checkout block.
- Fix shipping placeholder for the Checkout block when no shipping rates are available.
- Created a function in base/utils to format Shipping address.
- Remove the condition to check default customer address. Display the "Add shipping address" link only when there is no address available.
- Hide shipping calculator if default shipping  are defined.
@tarunvijwani tarunvijwani force-pushed the add/8027-shipping-address-link branch from 7ca092b to 52f902c Compare January 23, 2023 18:37
@tarunvijwani tarunvijwani changed the title Display the link to add the shipping address when the 'No location by default' is set for customer default location Display the link to add the shipping address when shipping address is available Jan 23, 2023
@tarunvijwani tarunvijwani changed the title Display the link to add the shipping address when shipping address is available Display the link to add the shipping address when shipping address is not available Jan 23, 2023
@tarunvijwani tarunvijwani marked this pull request as ready for review January 23, 2023 19:13
@tarunvijwani tarunvijwani requested a review from opr January 23, 2023 19:14
@woocommercebot woocommercebot requested a review from a team January 23, 2023 19:14
Copy link
Member

@mikejolley mikejolley left a comment

Choose a reason for hiding this comment

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

Something is broken here. I just tested with no default customer location in a new session, and this is what I got:

Screenshot 2023-01-24 at 11 40 14

No location is shown, and no shipping calculator is shown.

assets/js/base/utils/address.ts Show resolved Hide resolved
@@ -26,6 +26,7 @@ const Block = ( {
showRateSelector={ false }
values={ cartTotals }
currency={ totalsCurrency }
isCheckout={ true }
Copy link
Member

Choose a reason for hiding this comment

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

What was this for?

Copy link
Author

Choose a reason for hiding this comment

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

I found a bug on the checkout block page that displays Calculated during checkout for shipping in the Checkout summary if shipping options are unavailable. It happened because we were not passing the isCheckout prop to TotalsShipping component for Checkout. This change will fix it and display the correct error message.
image

Tarun Vijwani and others added 2 commits March 13, 2023 10:37
* Add further unit tests

* Add useStoreCart to mocked values and wrap in SlotFillProvider

* Add test for 2nd and 3rd scenario

* Remove AsyncModeProvider mock

Remove AsyncModeProvider mock since we are requiring @wordpress/data in setup-globals.js

---------

Co-authored-by: Thomas Roberts <[email protected]>
@tarunvijwani tarunvijwani modified the milestones: 9.8.0, 10.0.0 Mar 13, 2023
@tarunvijwani
Copy link
Author

This PR will be merged in the 1st week of April and released in the 10.0.0 version.

@tarunvijwani tarunvijwani added the status: on hold The issue is currently not prioritized or is awaiting something (for example, a fix upsteam). label Mar 13, 2023
mikejolley pushed a commit that referenced this pull request Mar 13, 2023
mikejolley pushed a commit that referenced this pull request Mar 13, 2023
…8679)

* Add CartCheckoutUtils class

This class will store reusable methods relating to Cart/Checkout Blocks, i.e. whether they are used on the Cart/Checkout page.

* Update ShippingController to use the new CartCheckoutUtils function

This will reduce code duplication when checking if the Cart/Checkout blocks are in use on the Cart/Checkout page.

* Add filter to remove shipping settings when Cart/Checkout are default

* Ensure setting displays correctly if cart is default but not checkout

* Add tests to ensure core shipping settings update correctly

* Add setCartCheckoutPages function to update set the cart/checkout page

* Force shipping to be enabled if the Checkout block is in use.

* Add filter to override cost requires address option

* Add shippingCostRequiresAddress option

* Check if the address is required before showing rates

* Show shipping rates in editor

* Add shippingCostRequiresAddress attribute to shipping methods block

* Update frontend type to show shippingCostRequiresAddress is a prop

* Add control to toggle shippingCostRequiresAddress option

* Show address notice in the correct scenario

* Send shippingCostRequiresAddress to Block in front end context

* Add e2e test for editor control

* Add e2e tests for shipping options on the front end

* Add updateAttributeInSiblingBlock function

* Add shippingCostRequiresAddress to shipping method block

* Ensure attribute is updated in both blocks when editing

* In Shipping Methods Block, show correct component based on block setting

* Show correct block in editor

* Remove broken test from PR

* Clean up updateAttributeInSiblingBlock

* Add setCartCheckoutPages function to update set the cart/checkout page

* Add tests to ensure core shipping settings update correctly

* Add isAddressComplete function

Borrowed from #8141

* Check if the address is required before showing rates

* Show shipping rates in editor

* Show address notice in the correct scenario

* Add e2e tests for shipping options on the front end

* Ensure errorId is passed to StateInput

* Add fullShippingAddressPushed action to wc/store/cart

* Add fullShippingAddressPushed case to reducer

* Ensure fullShippingAddressPushed is set when initialising cart store

* Add fullShippingAddressPushed selector and default state entry

* Add shippingAddressHasValidationErrors util function

* Do not overwrite addresses when selecting a rate

* Set whether full address has been pushed when saving address changes

* In Shipping Methods Block, show correct component based on block setting

* Don't show from price if rates should be hidden until address entered

* Check city validation errors to assert if shipping address is valid

* Rename merchant.js to merchant.ts

* Move local pickup functions to common merchant util

* Update local pickup tests to use common merchant utils

* Add test to ensure setting toggles in both blocks

* Add navigating to settings and saving in merchant util

* Create addPickupLocation merchant util

* Add test for local pickup and require full address

* Make sure correct conditions are met to show shipping options

* Ensure checkbox is checked during local pickup tests

* Unset the checkbox when tests are finished running

* Update checkout block fixture

* Prevent error in unit tests

* Import validation store key from constants

Required because importing from the index causes the validation data store to register twice

* Update checkout terms test to wait for button not to be disabled

* Revert "Add isAddressComplete function"

This reverts commit 9967dc0.
Tarun Vijwani added 3 commits March 16, 2023 12:08
Fix linting error that got introduced while resolving the merge conflict.
- Rename the isShippingAddressComplete variable to shippingAddressHasErrors as it only checks validation errors.
- Use isAddressComplete function to check if address is complete.
@tarunvijwani tarunvijwani requested review from rubikuserbot and a team and removed request for rubikuserbot March 16, 2023 09:26
Copy link
Contributor

@tarhi-saad tarhi-saad left a comment

Choose a reason for hiding this comment

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

@tarunvijwani, there is a logical error in the code! Please check my comment below!

? totalShippingValue
: // if address is not complete, display the link to add an address.
! addressComplete && (
<ShippingPlaceholder
Copy link
Contributor

Choose a reason for hiding this comment

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

@tarunvijwani, on the Checkout Block page, we would like to show the "ShippingPlaceholder" component when there are no shipping methods available (i.e., hasRates && cartHasCalculatedShipping). But, with this additional condition (i.e., ! addressComplete &&), the Shipping placeholder will never be displayed if the address is complete!

Copy link
Author

Choose a reason for hiding this comment

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

Continuing the discussion on slack: p1679930401191499-slack-C8X6Q7XQU

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
block: cart Issues related to the cart block. focus: settings Issues related to managing settings (including wc-settings). status: on hold The issue is currently not prioritized or is awaiting something (for example, a fix upsteam). type: enhancement The issue is a request for an enhancement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Display the link to add the shipping address when the "No location by default" is enabled
7 participants