| @@ -53,14 +53,14 @@ | ||
| 53 | 53 | * @param \Disco\App\Utility\Config $campaign Campaign. |
| 54 | 54 | */ |
| 55 | 55 | public static function discount_applies_to( array $rule, Config $campaign ): string { |
| 56 | 56 | if ( |
| 57 | - $rule['discount_type'] === 'percent' | |
| 58 | - || $rule['discount_type'] === 'fixed' | |
| 59 | - || $rule['discount_type'] === 'fixed_price' | |
| 57 | + 'percent' === $rule['discount_type'] | |
| 58 | + || 'fixed' === $rule['discount_type'] | |
| 59 | + || 'fixed_price' === $rule['discount_type'] | |
| 60 | 60 | ) { |
| 61 | 61 | $applies_to = 'line_item_subtotal'; |
| 62 | - } elseif ( $rule['discount_type'] === 'percent_per_product' || $rule['discount_type'] === 'fixed_per_product' ) { | |
| 62 | + } elseif ( 'percent_per_product' === $rule['discount_type'] || 'fixed_per_product' === $rule['discount_type'] ) { | |
| 63 | 63 | $applies_to = 'line_item'; |
| 64 | 64 | } elseif ( 'Product' === $campaign->get_discount_intent() ) { |
| 65 | 65 | $applies_to = 'product'; |
| 66 | 66 | } else { |
| @@ -100,9 +100,13 @@ | ||
| 100 | 100 | * @param \WC_Cart $cart Cart. |
| 101 | 101 | * @return float Cart Subtotal. |
| 102 | 102 | */ |
| 103 | 103 | public static function get_cart_subtotal( WC_Cart $cart ): float { |
| 104 | - // Get cart subtotal from cart if disco pro is active. | |
| 104 | + /** | |
| 105 | + * Get cart subtotal from cart if disco pro is active, | |
| 106 | + * if disco pro is not active, get cart subtotal from meta. | |
| 107 | + * It's for support Multi-currency plugin in disco pro. | |
| 108 | + */ | |
| 105 | 109 | if ( Disco::is_pro() ) { |
| 106 | 110 | return $cart->get_subtotal(); |
| 107 | 111 | } |
| 108 | 112 | |
| @@ -125,9 +129,9 @@ | ||
| 125 | 129 | */ |
| 126 | 130 | public static function get_free_quantity( array $rule, array $item ) { |
| 127 | 131 | $cart_qty = $item['quantity']; |
| 128 | 132 | |
| 129 | - if ( $rule['recursive'] === 'no' && $rule['min'] > 0 ) { | |
| 133 | + if ( 'no' === $rule['recursive'] && $rule['min'] > 0 ) { | |
| 130 | 134 | return $rule['get_quantity']; |
| 131 | 135 | } |
| 132 | 136 | |
| 133 | 137 | return floor( $cart_qty / $rule['min'] ) * $rule['get_quantity']; |