-
Notifications
You must be signed in to change notification settings - Fork 219
Update wc/store/cart
to handle hidden shipping costs until address is entered
#8682
Update wc/store/cart
to handle hidden shipping costs until address is entered
#8682
Conversation
Borrowed from #8141
The release ZIP for this PR is accessible via:
Script Dependencies ReportThe
This comment was automatically generated by the TypeScript Errors Report
assets/js/blocks/cart/cart-line-items-table/cart-line-item-row.tsx
assets/js/blocks/checkout/inner-blocks/checkout-shipping-method-block/edit.tsx assets/js/blocks/checkout/inner-blocks/checkout-shipping-methods-block/edit.tsx assets/js/data/cart/reducers.ts assets/js/editor-components/expandable-search-list-item/expandable-search-list-item.tsx assets/js/editor-components/product-attribute-term-control/index.js assets/js/editor-components/search-list-control/search-list-control.tsx assets/js/utils/attributes.ts |
Size Change: +682 B (0%) Total Size: 1.11 MB
ℹ️ View Unchanged
|
Required because importing from the index causes the validation data store to register twice
I believe the test failure in https://github.com/woocommerce/woocommerce-blocks/actions/runs/4379470384/jobs/7665457556 is not related to this PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've successfully tested the PR, but noticed that isAddressComplete()
seems to be defined, but not used. I've added a note on that.
This reverts commit 9967dc0.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After the recent change, I tested this PR again, and it's still working as expected. Let's ⛴ this change.
I'm not going to block this work being merged but I should point out, if we end up going with a modal or step based flow on the checkout, tracking whether the address has been pushed will no longer be necessary because the shipping step won't be refreshed until the user has input their address cc @ralucaStan |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested as described.
This PR is based on
add/hide-costs-control
#8680 and is part of the work required to satisfy #7895In this PR, the changes made include updates to the
wc/store/cart
data store, to track when an address is complete.These changes are required the purposes of showing shipping rates only when an address is complete, and also tracks whether the complete address has been pushed to the server. This check is required to prevent showing outdated shipping methods in the event that an address becomes complete, but has not been pushed to the server yet, and shipping methods are not updated.
This had to be done in the data store rather than the API because the setting to Hide shipping costs until an address is entered is now a block setting, and altering the API to show only local pickup options would not be possible. If it were done in the Store API and there were two Checkout blocks on the site the Store API would only return correct data for one of the blocks.
There was also a scenario where entering a complete address would instantly trigger a rate selection (when the rate radio buttons got rendered) and if the user was entering their address at that time, then the address returned by the API during the
selectShippingRate
action would be missing the field the user was editing (because that field was not pushed to the server yet) and that would update the form, thus deleting the user's currently entered text. To avoid this, theshipping_address
andbilling_address
keys are removed from the response when updating the cart data following a shipping rate selection.This PR also updates the local pickup e2e tests. The changes made here are:
tests/utils/merchant.ts
) and improve the DX of using these functions (i.e. theenableLocalPickup
function also includes navigating to the settings page).Hide shipping costs until an address is entered
setting correctly prevents rates from appearing until the address is fully entered.Testing
Automated Tests
User Facing Testing
WooCommerce -> Settings -> Shipping -> Local Pickup
, enable Local Pickup and add a location.Hide shipping costs until an address is entered
option.Default customer location
toNo location by default
.calculated with an address
Hide shipping costs until an address is entered
in the editor and ensure the rates show as usual, even without a full address.WooCommerce Visibility
Performance Impact
Changelog