-
Notifications
You must be signed in to change notification settings - Fork 10.7k
Fix "Out of stock threshold" when filed value is empty - Fix/issue 36960 #37855
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
Conversation
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## trunk #37855 +/- ##
========================================
Coverage 51.5% 51.5%
+ Complexity 17283 17281 -2
========================================
Files 430 430
Lines 80037 80031 -6
========================================
+ Hits 41216 41218 +2
+ Misses 38821 38813 -8
|
jorgeatorres
left a comment
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.
Hi @bartech,
Thank you for your contribution! This looks good to me. I just left a tiny little bit of feedback. Once that's addressed, we'll be good to merge! 💯
Thanks again!
| $this->label = __( 'Products', 'woocommerce' ); | ||
|
|
||
| parent::__construct(); | ||
| add_filter( 'woocommerce_admin_settings_sanitize_option_woocommerce_notify_no_stock_amount', 'absint' ); |
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.
A while ago we added a class to handle this kind of "one off" sanitization, which might be better suited given we've been trying to modernize the codebase a bit. The class is called OptionSanitizer and you can find it in plugins/woocommerce/src/Internal/Settings/OptionSanitizer.php.
In the constructor over there, you can add this same add_filter().
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.
@jorgeatorres Filter moved, please give it another look.
jorgeatorres
left a comment
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.
LGTM! 💯
Thank you again @bartech for your contribution.
Submission Review Guidelines:
Changes proposed in this Pull Request:
This PR
woocommerce_admin_settings_sanitize_option_woocommerce_notify_no_stock_amountfilter.@param $notify_no_stock_amounttype in testsCloses #36960 .
How to test the changes in this Pull Request:
Using the WooCommerce Testing Instructions Guide, include your detailed testing instructions:
WooCommerce Settings -> Products -> Inventory.NOTE:
We should consider do same casting on save for "Low stock threshold" field.
Or in general we should add new case for all
numbertype fields and when empty set to default value.woocommerce/plugins/woocommerce/includes/admin/class-wc-admin-settings.php
Lines 832 to 870 in 8ac3c29