| @@ -44,9 +44,10 @@ | ||
| 44 | 44 | * @throws \Exception If settings not found. |
| 45 | 45 | */ |
| 46 | 46 | public function get_discounts( $items, $cart ) { // phpcs:ignore |
| 47 | 47 | |
| 48 | - $discount = 0; | |
| 48 | + $discount = 0; | |
| 49 | + $discount_type = ''; | |
| 49 | 50 | |
| 50 | 51 | if ( empty( $items ) ) { |
| 51 | 52 | return $discount; |
| 52 | 53 | } |
| @@ -74,9 +75,9 @@ | ||
| 74 | 75 | // $cost = $this->get_items_subtotal( $items ); |
| 75 | 76 | $cost = $this->get_items_subtotal_based_on_settings( $items ); |
| 76 | 77 | |
| 77 | 78 | // Discount should be less than item price |
| 78 | - if ( $discount_type === 'fixed_per_product' ) { | |
| 79 | + if ( 'fixed_per_product' === $discount_type ) { | |
| 79 | 80 | // TODO: Check there is no free products in the cart before counting the discount |
| 80 | 81 | $item_prices = array(); |
| 81 | 82 | |
| 82 | 83 | foreach ( $items as $item ) { |
| @@ -91,9 +92,8 @@ | ||
| 91 | 92 | $discount = $this->calculate_discount( $cost, $discount_type, $discount_value ); |
| 92 | 93 | } |
| 93 | 94 | } |
| 94 | 95 | |
| 95 | - // @phpstan-ignore-next-line | |
| 96 | 96 | return apply_filters( 'disco_final_discounted_amount', $discount, $discount_type ); |
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | |