Skip to content

Instantly share code, notes, and snippets.

@corsonr
Last active September 25, 2022 09:17
Show Gist options
  • Save corsonr/ae2611b9ac34bec1a3c1fbb1c8432b04 to your computer and use it in GitHub Desktop.
Save corsonr/ae2611b9ac34bec1a3c1fbb1c8432b04 to your computer and use it in GitHub Desktop.
WooCommerce: redirect user upon coupon removal

WooCommerce: Redirect user to a specific page after removing a coupon

This snippet gives the ability to redirect a user after removing a coupon. You can place the code in functions.php.

<?php // Do not include this if already open! Code goes in theme functions.php.
/*
* Redirects user to a specific page upon coupon removal.
*/
function action_woocommerce_removed_coupon( $coupon_code ) {
// Redirection...
wp_redirect( $url ); // Replace $url by your page URL.
exit;
};
// add the action
add_action( 'woocommerce_removed_coupon', 'action_woocommerce_removed_coupon', 10, 1 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment