Fix entities in coupon validation error messages (https://github.com/woocommerce/woocommerce-blocks/pull/2179)
* decodeEntities in error messages * Add unslash to coupon field * Decode when receiving error
This commit is contained in:
parent
ace2d2bd81
commit
ceaae16d23
|
@ -7,6 +7,7 @@ import { __, sprintf } from '@wordpress/i18n';
|
|||
import { useSelect } from '@wordpress/data';
|
||||
import { CART_STORE_KEY as storeKey } from '@woocommerce/block-data';
|
||||
import { useValidationContext } from '@woocommerce/base-context';
|
||||
import { decodeEntities } from '@wordpress/html-entities';
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
|
@ -59,7 +60,10 @@ export const useStoreCartCoupons = () => {
|
|||
} )
|
||||
.catch( ( error ) => {
|
||||
setValidationErrors( {
|
||||
coupon: { message: error.message, hidden: false },
|
||||
coupon: {
|
||||
message: decodeEntities( error.message ),
|
||||
hidden: false,
|
||||
},
|
||||
} );
|
||||
// Finished handling the coupon.
|
||||
receiveApplyingCoupon( '' );
|
||||
|
|
|
@ -59,7 +59,7 @@ class CartApplyCoupon extends AbstractCartRoute {
|
|||
|
||||
$controller = new CartController();
|
||||
$cart = $controller->get_cart_instance();
|
||||
$coupon_code = wc_format_coupon_code( $request['code'] );
|
||||
$coupon_code = wc_format_coupon_code( wp_unslash( $request['code'] ) );
|
||||
|
||||
try {
|
||||
$controller->apply_coupon( $coupon_code );
|
||||
|
|
Loading…
Reference in New Issue