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
Add a filter for the items to apply coupons array. #45791
Conversation
Hi @budzanowski, Apart from reviewing the code changes, please make sure to review the testing instructions as well. You can follow this guide to find out what good testing instructions should look like: |
Test Results SummaryCommit SHA: e34fe28
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. |
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.
Looks good but we need the documentation.
@@ -333,7 +333,7 @@ protected function get_items_to_apply_coupon( $coupon ) { | |||
|
|||
$items_to_apply[] = $item_to_apply; | |||
} | |||
return $items_to_apply; | |||
return apply_filters( 'woocommerce_coupon_get_items_to_apply', $items_to_apply, $coupon, $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.
This needs docblock. Please review https://developer.wordpress.org/coding-standards/inline-documentation-standards/php/ for guidance.
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 @budzanowski . I added the missing docbloc here: ace39fa
Submission Review Guidelines:
Changes proposed in this Pull Request:
I am working on an issue where fixed_cart coupon needs to be applied to only a subset of the cart items. The items to apply coupon array is built by get_items_to_apply_coupon method in WC_Discounts class.
I propose a filter in get_items_to_apply_coupon modify the items to apply coupons to.
Closes #45790 .
How to test the changes in this Pull Request:
Using the WooCommerce Testing Instructions Guide, include your detailed testing instructions:
You can use the filter in your child's theme's function.php file.
Changelog entry
Significance
Type
Message
WC_Discount: Add a filter for the items to apply coupons array.
Comment