WC_Discounts::validate_coupon_maximum_amount( WC_Coupon $coupon )
Ensure coupon amount is valid or throw exception.
Description Description
Parameters Parameters
- $coupon
-
(Required) Coupon data.
Return Return
(bool)
Source Source
File: includes/class-wc-discounts.php
protected function validate_coupon_maximum_amount( $coupon ) {
$subtotal = wc_remove_number_precision( $this->get_object_subtotal() );
if ( $coupon->get_maximum_amount() > 0 && apply_filters( 'woocommerce_coupon_validate_maximum_amount', $coupon->get_maximum_amount() < $subtotal, $coupon ) ) {
/* translators: %s: coupon maximum amount */
throw new Exception( sprintf( __( 'The maximum spend for this coupon is %s.', 'woocommerce' ), wc_price( $coupon->get_maximum_amount() ) ), 112 );
}
return true;
}
Changelog Changelog
| Version | Description |
|---|---|
| 3.2.0 | Introduced. |