Created
February 9, 2015 08:46
-
-
Save amdrew/6d98891e0a958f71240f to your computer and use it in GitHub Desktop.
Easy Digital Downloads - Add download to cart if the cart is empty
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Add product to cart if cart is empty | |
*/ | |
function sumobi_edd_add_to_cart_if_empty() { | |
$download_to_add = 123; | |
$cart = function_exists( 'edd_get_cart_contents' ) ? edd_get_cart_contents() : false; | |
if ( function_exists( 'edd_is_checkout' ) && edd_is_checkout() && ! $cart ) { | |
edd_add_to_cart( $download_to_add ); | |
} | |
} | |
add_action( 'template_redirect', 'sumobi_edd_add_to_cart_if_empty', 9 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment