-
Notifications
You must be signed in to change notification settings - Fork 219
Hide the shipping address form from Checkout Block in Editor and rename the Billing Address label when "Force shipping to the customer billing address" is enabled. #7800
Conversation
…hen Force shipping to the customer billing address is enabled
The release ZIP for this PR is accessible via:
|
TypeScript Errors ReportFiles with errors: 431 🎉 🎉 This PR does not introduce new TS errors. |
Size Change: +288 B (0%) Total Size: 972 kB
ℹ️ View Unchanged
|
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.
Hey @tarunvijwani thanks for working on this, it looks great! I have added a few comments, but nothing major.
|
||
export default { | ||
export const attributes: Record< string, Record< string, unknown > > = { |
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.
Could we use the Gutenberg type BlockAttributes
here?
You'd need to import { BlockAttributes } from '@wordpress/blocks';
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.
Yes, that's a better way to define types. Added the BlockAttributes
type. 👍
|
||
if ( forcedBillingAddress ) { | ||
attributes.title = | ||
attributes.title === DEFAULT_TITLE |
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.
This ternary operator is a little hard to reason with, maybe adding comments would be useful here.
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 would also consider if we need the if/else
structure here, or if it would be better to move this logic into a separate function, remove the use of ternary operators and make this easier to read, what do you think?
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.
That's actually a good idea! I have moved the logic to a different function and added the comments for better understanding. Thank you! 🙂
@@ -43,7 +49,19 @@ const FrontendBlock = ( { | |||
if ( ! showBillingFields && ! forcedBillingAddress ) { | |||
return null; | |||
} | |||
|
|||
if ( forcedBillingAddress ) { |
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.
Please see my comment about if/else
and ternary operators in the edit.tsx
file and consider if the same applies here.
|
||
export default { |
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.
How come we removed this and now only export a named const?
Should we add export default attributes
at the bottom of this file?
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.
Ah, I missed that. This is fixed now. Thank you!
…efault export for attributes
Script Dependencies ReportThere is no changed script dependency between this branch and trunk. This comment was automatically generated by the |
forcedBillingAddress: boolean | ||
): string => { | ||
if ( forcedBillingAddress ) { | ||
// returns default forced billing title when forced billing address is enabled and there is no title set |
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.
Slight nit pick on these comments: please ensure we follow the WP Coding guidelines here: https://developer.wordpress.org/coding-standards/wordpress-coding-standards/javascript/#comments
Besides this, these new functions look good!
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.
Thank you for the guide! I have fixed the comments. 👍
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.
Great work Tarun, this looks good to merge now! 🥳
In PRs #7268 and #7393, we hide the shipping address form from the front end for the Checkout block when
Force shipping to the customer billing address
is enabled.In this PR, we hide the shipping address form from the Editor and rename the billing address label when
Force shipping to the customer billing address
is enabled.Fixes #7513
Fixes #7394
Changes in the PR
Accessibility
prefers-reduced-motion
Other Checks
Screenshots
Testing
Automated Tests
User Facing Testing
wp-admin/admin.php?page=wc-settings&tab=shipping§ion=options
page.Force shipping to the customer billing address
option and save the changes.Billing and shipping address
and the description isEnter the billing and shipping address that matches your payment method.
Billing and shipping address
and the description isEnter the billing and shipping address that matches your payment method.
Force shipping to the customer billing address
option and save the changes.WooCommerce Visibility
Performance Impact
Changelog