Skip to content

Commit c5cf6b6

Browse files
fix case sensitive apply coupon mutation (#729)
The applyCoupon mutation is case sensitive, but coupons are not. This fixes trying to add a coupon code with lower case letters, such as `10off`. Previously you would get an error that the coupon doesn't exist because of mismatch in the case.
1 parent f55404e commit c5cf6b6

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

includes/data/mutation/class-cart-mutation.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ public static function validate_coupon( $code, &$reason = '' ) {
170170
$the_coupon = new \WC_Coupon( $code );
171171

172172
// Prevent adding coupons by post ID.
173-
if ( $the_coupon->get_code() !== $code ) {
173+
if ( strtoupper( $the_coupon->get_code() ) !== strtoupper( $code ) ) {
174174
$reason = __( 'No coupon found with the code provided', 'wp-graphql-woocommerce' );
175175
return false;
176176
}

0 commit comments

Comments
 (0)