WordPress at Your Fingertips
function is not described

WC_AJAX::remove_coupon() public WC 1.0

AJAX remove coupon on cart and checkout page.

{} It's a method of the class: WC_AJAX{}

No Hooks.

Return

null. Nothing.

Usage

$result = WC_AJAX::remove_coupon();

Code of WC_AJAX::remove_coupon() WC 5.9.0

public static function remove_coupon() {
	check_ajax_referer( 'remove-coupon', 'security' );

	$coupon = isset( $_POST['coupon'] ) ? wc_format_coupon_code( wp_unslash( $_POST['coupon'] ) ) : false; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized

	if ( empty( $coupon ) ) {
		wc_add_notice( __( 'Sorry there was a problem removing this coupon.', 'woocommerce' ), 'error' );
	} else {
		WC()->cart->remove_coupon( $coupon );
		wc_add_notice( __( 'Coupon has been removed.', 'woocommerce' ) );
	}

	wc_print_notices();
	wp_die();
}