Search for a plugin or theme

How To Redirect WooCommerce and EDD Empty Checkout Pages

You are currently viewing How To Redirect WooCommerce and EDD Empty Checkout Pages

The empty checkout page is no fun. Not for the store owner nor the website visitor.

Besides the fact that it’s not user-friendly, you also going to lose revenue in the long run when the cart page has no items.

When the user removes items from the cart, there is a better chance for him to navigate away from your website afterward. To prevent it from happening, it will be better to direct them into some of the products that may interest them.

Take a look at our website for example. When you try to load our checkout page pluginsforwp.com/checkout when it’s empty, you’ll be redirected to our subscription page.

By doing so, I focused your attention on our available plans and saved you valuable page load time.

In this tutorial, we will redirect WooCommerce and Easy Digital Downloads empty cart pages to different pages.

Both codes below need to be paste in the functions.php file of your child theme or in a site-specific plugin. Read our article and learn how to create a custom site-specific plugin in WordPress.

WooCommerce extensions

Redirect empty checkout page for WooCommerce

If you’re using the WooCommerce plugin to sell your goods, use the code below


function pfwp_redirection_function(){
	global $woocommerce;
	if( is_cart() && WC()->cart->cart_contents_count == 0){
		$page_id = 1;
		wp_redirect( get_the_permalink( $page_id ) );
	}
}
add_action("template_redirect", 'pfwp_redirection_function', 11);

Redirect empty checkout page for Easy Digital Downloads

If you’re using the EDD plugin to sell your goods, use the code below

function edd_redirect_empty_cart_to_unlimited_downloads(){
	if ( is_page( edd_get_option( 'purchase_page' ) ) && edd_get_cart_quantity() == 0 ) {
		$page_id = 1;
		wp_redirect( get_the_permalink( $page_id ) );
		exit;
	}
}
add_action( 'template_redirect', 'edd_redirect_empty_cart_to_unlimited_downloads', 11 );

In both codes, change the $page_id number to the desired page ID number.

Related Articles

Conclusion

In this article, you learn how to redirect empty checkout pages to another page.

Let us know which code snippet you used to achieve that.

Also, make sure to subscribe to our YouTube channel and like our page on Facebook.

Share on facebook
Share on twitter
Share on linkedin
Share on pinterest
Share on email

PluginsForWP

PluginsForWP is a website specializing in redistributing WordPress plugins and themes with a variety of knowledge about WordPress, internet marketing, and blogging.

Leave a Reply