Add a filter for the items to apply coupons array. (#45791)

* Add a filter for the items to apply coupons array.

* Add changefile(s) from automation for the following project(s): woocommerce

* Add filter docbloc.

* Add since tag in filter docbloc.

---------

Co-authored-by: github-actions <github-actions@github.com>
This commit is contained in:
Rodrigue 2024-03-25 17:23:47 +02:00 committed by GitHub
parent 2403baca01
commit b3a1d8c922
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 18 additions and 1 deletions

View File

@ -0,0 +1,4 @@
Significance: minor
Type: tweak
WC_Discount: Add a filter for the items to apply coupons array.

View File

@ -333,7 +333,20 @@ class WC_Discounts {
$items_to_apply[] = $item_to_apply;
}
return $items_to_apply;
/**
* Filters the items that a coupon should be applied to.
*
* This filter allows you to modify the items that a coupon will be applied to before the discount calculations take place.
*
* @since 8.8.0
* @param array $items_to_apply The items that the coupon will be applied to.
* @param WC_Coupon $coupon The coupon object.
* @param WC_Discounts $this The discounts instance.
*
* @return array The modified list of items that the coupon should be applied to.
*/
return apply_filters( 'woocommerce_coupon_get_items_to_apply', $items_to_apply, $coupon, $this );
}
/**