WC_AJAX::apply_coupon()
AJAX apply coupon on checkout page.
Description Description
Source Source
File: includes/class-wc-ajax.php
public static function apply_coupon() { check_ajax_referer( 'apply-coupon', 'security' ); if ( ! empty( $_POST['coupon_code'] ) ) { WC()->cart->add_discount( wc_format_coupon_code( wp_unslash( $_POST['coupon_code'] ) ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized } else { wc_add_notice( WC_Coupon::get_generic_coupon_error( WC_Coupon::E_WC_COUPON_PLEASE_ENTER ), 'error' ); } wc_print_notices(); wp_die(); }