Easy Digital Downloads by default has no cart enabled. We’ve built our ticket plugins around the default behavior. But they do provide a shortcode to include a cart and if you use it the ticket sales flow will skip over it.

That’s not ideal, so we’ve whipped up this snippet to put in your functions.php to add detection of the cart to the checkout flow:

add_filter( 'tribe_tickets_plus_edd_cart_url', 'detect_edd_shortcode_cart');

/**
 * Get URL of EDD shortcode cart - if it is in use. 
 * If so use it for the tickets cart URL instead of checkout.
 *
 * @return string|null The url or null if the shortcode is not in use.
 */
function detect_edd_shortcode_cart() {
	global $wpdb;
	/** @var \Tribe__Tickets_Plus__Commerce__EDD__Cart $edd_cart */
	$edd_cart        = tribe( 'tickets-plus.commerce.edd.cart' );
	/** @var \Tribe__Tickets_Plus__Commerce__EDD__Main $ticket_provider */
	$ticket_provider = tribe( 'tickets-plus.commerce.edd' );

	// Look for a post with the shortcode.
	$query         = "SELECT ID, guid FROM {$wpdb->posts} WHERE post_content LIKE '%[download_cart]%' AND post_status       = 'publish' LIMIT 1";
	$results       = $wpdb->get_results($query);
	// Parse the results for the permalink.
	$shortcode_url = ( ! empty( $results[0]->guid ) ) ? get_permalink( $results[0]->ID ) : null;
	$cart_url      = empty( $shortcode_url ) ? $edd_cart->get_checkout_url() : $shortcode_url;

	// Add some query args for the cart/checkout/attendee registration checks.
	$cart_url = add_query_arg(
		[
			'eddtickets_process' => 1,
			'provider'           => $ticket_provider::ATTENDEE_OBJECT,
		],
		$cart_url
	);

	return $cart_url;
}

Notes:

  • Originally written in November 2019
  • Tested with Event Tickets 4.11.0
  • Author: Stephen Page

As with all of our snippets, please note that we share this in the hope it will be useful but without any guarantees or commitments. If you wish to use it, it is your responsibility to test it first of all and adapt it to your needs (or find someone who can do so on your behalf). We are unable to provide further support in relation to this recipe.