Skip to content

Instantly share code, notes, and snippets.

@amdrew
Last active October 18, 2022 23:03
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amdrew/11197579 to your computer and use it in GitHub Desktop.
Save amdrew/11197579 to your computer and use it in GitHub Desktop.
Easy Digital Downloads - redirect when cart is empty
<?php
function sumobi_edd_empty_cart_redirect() {
$cart = function_exists( 'edd_get_cart_contents' ) ? edd_get_cart_contents() : false;
$redirect = site_url( 'shop' ); // could be the URL to your shop
if ( function_exists( 'edd_is_checkout' ) && edd_is_checkout() && ! $cart ) {
wp_redirect( $redirect, 301 );
exit;
}
}
add_action( 'template_redirect', 'sumobi_edd_empty_cart_redirect' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment