Merge pull request #19161 from Chouby/fatal_wc_discounts

Fix fatal error in PHP < 5.5
This commit is contained in:
Mike Jolley 2018-02-28 12:05:16 +00:00 committed by GitHub
commit ca7414e40d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 2 deletions

View File

@ -757,10 +757,11 @@ class WC_Discounts {
* @return bool
*/
protected function validate_coupon_excluded_items( $coupon ) {
if ( ! empty( $this->get_items_to_validate() ) && $coupon->is_type( wc_get_product_coupon_types() ) ) {
$items = $this->get_items_to_validate();
if ( ! empty( $items ) && $coupon->is_type( wc_get_product_coupon_types() ) ) {
$valid = false;
foreach ( $this->get_items_to_validate() as $item ) {
foreach ( $items as $item ) {
if ( $item->product && $coupon->is_valid_for_product( $item->product, $item->object ) ) {
$valid = true;
break;