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
Convert "Allow backorders?" into radio buttons #37282
Convert "Allow backorders?" into radio buttons #37282
Conversation
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## trunk #37282 +/- ##
========================================
Coverage 45.8% 45.8%
Complexity 17196 17196
========================================
Files 429 429
Lines 64909 64911 +2
========================================
+ Hits 29701 29705 +4
+ Misses 35208 35206 -2
|
Test Results SummaryCommit SHA: 2786b10
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. |
4e2c8e5
to
138e36a
Compare
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.
The default for the filter needs to be flipped. Ping me when ready for a re-review!
* | ||
* @param bool If false, "Allow backorders?" will be shown as a select. Default: it will use radio buttons. | ||
*/ | ||
if ( apply_filters( 'woocommerce_product_allow_backorder_use_radio', false ) ) { |
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.
The default should be true
, otherwise, the radios are not used by default!
if ( apply_filters( 'woocommerce_product_allow_backorder_use_radio', false ) ) { | ||
woocommerce_wp_radio( $common_backorder_args ); | ||
} else { | ||
$select_input_args = array( | ||
'desc_tip' => true, |
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.
Same comment as on #37278... I think we should keep the tip.
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.
Tests well. Nice job! 🚀
$stock_status_options = wc_get_product_stock_status_options(); | ||
$stock_status_count = count( $stock_status_options ); | ||
$stock_status_args = array( | ||
'id' => '_stock_status', | ||
'value' => $product_object->get_stock_status( 'edit' ), | ||
'wrapper_class' => 'stock_status_field hide_if_variable hide_if_external hide_if_grouped', | ||
'label' => __( 'Stock status', 'woocommerce' ), | ||
'options' => $stock_status_options, | ||
'desc_tip' => true, | ||
'description' => __( 'Controls whether or not the product is listed as "in stock" or "out of stock" on the frontend.', 'woocommerce' ), |
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.
These changes are not directly related to the PR. It would be good in the future to either split them out or, since this is admittedly a small change and closely related, just reference that the change was made in the PR description/comments, so it is clear to the reviewer!
All Submissions:
Changes proposed in this Pull Request:
This PR adds the code to convert the "Allow backorders?" dropdown into radio buttons.
If the number of items inside exceeds three, it should be displayed as a dropdown again.
Closes #37118.
How to test the changes in this Pull Request:
Products
>Add New
>Product data
>Inventory
.Allow backorders?
uses a radio button to set that option.select
instead of theradio
buttons.Other information:
pnpm --filter=<project> changelog add
?FOR PR REVIEWER ONLY: