Easy Digital Downloads is a great piece of software if you’re selling plugins and themes. I’m using it on the Wisdom plugin site (Wisdom allows plugin developers to get information about where and how their plugins are being used). Because this website only sells one product, I’ve enabled the EDD feature to redirect the user straight to the checkout page after adding the product to their basket.

What this can mean is that a user might click on the Checkout link in the main navigation menu when they haven’t yet added the product to the cart. By default, Easy Digital Downloads just shows a simple message in this situation:

It’s fine as far as it goes: it’s factually accurate but doesn’t provide the user with any further options. (The default WooCommerce checkout page adds a ‘Return to Store’ button if there’s nothing in the cart). However, rather than just add a link back to the homepage, I thought it would be better to add a widget area to this page that would allow me to be more flexible with additional content – notably, I wanted to add the option for the user to add the product to their cart direct from this page without needing to go elsewhere on the site.

In the theme’s functions.php file, I registered a new widget area specifically for the empty checkout page:

function singularity_widgets_init() {
  register_sidebar( array(
   'name' => esc_html__( 'EDD Empty Checkout Page', 'singularity' ),
   'id' => 'empty-checkout-page',
   'description' => esc_html__( 'Add widgets here.', 'singularity' ),
   'before_widget' => '<section id="%1$s" class="widget %2$s">',
   'after_widget' => '</section>',
   'before_title' => '<h5 class="widget-title">',
   'after_title' => '</h5>',
  ) );
}
add_action( 'widgets_init', 'singularity_widgets_init' );

(Note that I’m using a theme I’ve developed myself so I’m happy adding this to the functions.php file. If you’re using a commercial theme, you should probably be using a child theme.)

Because EDD is well coded it was easy to find a hook – edd_cart_empty – that I could use to add the widget area. Note that this hook only fires if the checkout page is empty – we don’t want to display this additional content when the user has a product in their cart.

function singularity_add_widget_to_checkout() {
  dynamic_sidebar( 'empty-checkout-page' );
}
add_action( 'edd_cart_empty', 'singularity_add_widget_to_checkout' );

Now, there’s a new widget area available on the page when the checkout is empty. I added the Download Details widget and now the user can purchase the product direct from the empty checkout page.

Of course, you can add any content here you want. It just seemed that the purchase shortcode was the most natural – especially on a site selling just one product.

EDD Empty Cart

You could, as it turns out, use the EDD Empty Cart plugin to achieve something similar – though this particular extension doesn’t include a widget area.

Published by Catapult Themes

    Leave a Reply

    Your email address will not be published. Required fields are marked *