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
Show message in Inventory tab for variable products #37185
Conversation
Test Results SummaryCommit SHA: 4175251
To view the full API test report, click here. To view the full E2E test report, click here. To view all test reports, visit the WooCommerce Test Reports Dashboard. |
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## trunk #37185 +/- ##
========================================
Coverage 46.7% 46.7%
Complexity 17191 17191
========================================
Files 429 429
Lines 64845 64845
========================================
Hits 30275 30275
Misses 34570 34570
|
<div class="inline notice woocommerce-message show_if_variable"> | ||
<p> | ||
<?php echo esc_html_e( 'Settings below apply to all variations without manual stock management enabled. ', 'woocommerce' ); ?> <a target="_blank" href="https://woocommerce.com/document/variable-product/"><?php esc_html_e( 'Learn more', 'woocommerce' ); ?></a> | ||
</p> | ||
</div> |
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.
We can abstract this (and every use of this kind of message) in a follow-up PR. We might create a method like woocommerce_wp_notice
or woocommerce_wp_message
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.
Any reason not to just abstract it in this PR? Do you question whether it should be abstracted?
I don't feel strongly whether it should be at this point, but would lean slightly towards doing so in this PR.
I'll review this |
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. Overall, works as expected.
There are a few minor styling tweaks that should be made to ensure that this message looks ideal.
@@ -959,12 +959,16 @@ | |||
} | |||
|
|||
#variable_product_options #message, | |||
#inventory_product_data .notice, | |||
#variable_product_options .notice { | |||
display: flex; | |||
margin: 10px; | |||
background-color: #ffffff; | |||
> p { | |||
width: 85%; |
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.
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.
Nice catch! I couldn't delete it because we will need the 85% when there is a button, like here:
But I added the code we need for that case in the commit 5108e42.
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.
#variable_product_options .notice { | ||
display: flex; | ||
margin: 10px; | ||
background-color: #ffffff; | ||
> p { | ||
width: 85%; | ||
a { | ||
text-decoration: none; |
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.
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.
Good idea!
|
||
<div class="inline notice woocommerce-message show_if_variable"> | ||
<p> | ||
<?php echo esc_html_e( 'Settings below apply to all variations without manual stock management enabled. ', 'woocommerce' ); ?> <a target="_blank" href="https://woocommerce.com/document/variable-product/"><?php esc_html_e( 'Learn more', 'woocommerce' ); ?></a> |
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.
There is an errant space at the end of the translated message. enabled.
That space is not needed.
<div class="inline notice woocommerce-message show_if_variable"> | ||
<p> | ||
<?php echo esc_html_e( 'Settings below apply to all variations without manual stock management enabled. ', 'woocommerce' ); ?> <a target="_blank" href="https://woocommerce.com/document/variable-product/"><?php esc_html_e( 'Learn more', 'woocommerce' ); ?></a> | ||
</p> | ||
</div> |
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.
Any reason not to just abstract it in this PR? Do you question whether it should be abstracted?
I don't feel strongly whether it should be at this point, but would lean slightly towards doing so in this PR.
@mattsherman Yes, I think that it should be refactored but that refactor implies also touching code in 4 different files (wc-admin-functions, html-product-data-attributes, html-product-data-variations, and html-product-data-inventory). I prefer to wrap those changes in a different PR and only add the message in this one, to keep this PR small. |
Hey @mattsherman, |
Makes sense. |
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.
Thanks for fixing things up, @octaedro ! Nice work. Approved.
white-space: nowrap; | ||
} | ||
} | ||
> p:not( :last-child ) { |
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.
As mentioned, this explicit width causes issues but it outside the scope of this PR, so I'm good with this fix for now!
All Submissions:
Changes proposed in this Pull Request:
This PR adds the code to show a message in the
Inventory
tab when the product is type variable.Closes #37119.
How to test the changes in this Pull Request:
Products
>Add New
>Product data
>Inventory
.Settings below apply to all variations without manual stock management enabled. [Learn more](https://woocommerce.com/document/variable-product/)
is not visible.Variable product
and check that now the message is visible.Other information:
pnpm --filter=<project> changelog add
?FOR PR REVIEWER ONLY: