| 1 |
<?php |
| 2 |
// phpcs:disable |
| 3 |
/** |
| 4 |
* Disco |
| 5 |
* |
| 6 |
* @package Disco |
| 7 |
* @author Ohidul Islam <wahid0003@gmail.com> |
| 8 |
* @link http://domain.tld |
| 9 |
* @license GPL 2.0+ |
| 10 |
* @copyright 2022 WebAppick |
| 11 |
*/ |
| 12 |
|
| 13 |
// Ensure the file is not accessed directly. |
| 14 |
if (!defined('ABSPATH')) { |
| 15 |
exit; |
| 16 |
} |
| 17 |
|
| 18 |
use Disco\App\Utility\Settings; |
| 19 |
|
| 20 |
if( ! function_exists( 'disco_get_coupon_discount' ) ) { |
| 21 |
|
| 22 |
/** |
| 23 |
* Get the discount amount for a coupon. |
| 24 |
* |
| 25 |
* @param string $coupon_code Coupon code. |
| 26 |
* @return float |
| 27 |
*/ |
| 28 |
function disco_disable_coupon_application( $valid, $coupon, $discount ) { |
| 29 |
if ( Settings::get( 'discount_priority_type' ) === 'both' ) { |
| 30 |
return $valid; // Allow coupon validation if the setting is enabled. |
| 31 |
} |
| 32 |
return false; // This will prevent all coupons from being valid |
| 33 |
} |
| 34 |
|
| 35 |
add_filter( 'woocommerce_coupon_is_valid', 'disco_disable_coupon_application', 10, 3 ); |
| 36 |
} |
| 37 |
|
| 38 |
|
| 39 |
|