EDD Checkout page generation


The WordPress site has a handy page which shows the actions performed as a request is processed. A similar thing is useful for EDD when working out which actions to augment or replace in a theme or plugin. This is a review of the actions for the generating the checkout page.

Here’s a list of the actions in the order in which they are executed by EDD Checkout page generation followed by a review of the code and how the checkout page is generated.

	'edd_before_checkout_cart'
	<form>
		'edd_checkout_table_header_first'
		'edd_checkout_table_header_last'
		'edd_cart_items_before'
		'edd_checkout_table_body_first'
		'edd_checkout_table_body_last'
		'edd_cart_items_after'
		'edd_cart_footer_buttons'
		'edd_checkout_table_subtotal_first'
		'edd_checkout_table_subtotal_last'
		'edd_checkout_table_tax_first'
		'edd_checkout_table_tax_last'
		'edd_checkout_table_discount_first'
		'edd_checkout_table_discount_last'
		'edd_checkout_table_footer_first'
		'edd_checkout_table_footer_last'
	</form>
	'edd_after_checkout_cart'
	'edd_before_purchase_form'
	<form>
		'edd_checkout_form_top'
		'edd_payment_mode_select' || 'edd_purchase_form'
			'edd_purchase_form_top'
			'edd_purchase_form_before_register_login'
			'edd_purchase_form_register_fields' || 'edd_purchase_form_login_fields'
			'edd_purchase_form_after_user_info'
				'edd_purchase_form_user_info'
			'edd_purchase_form_before_cc_form'
			'edd_' . $payment_mode . '_cc_form' || 'edd_cc_form'
			'edd_purchase_form_after_cc_form'
			'edd_purchase_form_bottom'
		'edd_checkout_form_bottom'
	</form>
	'edd_after_purchase_form'

The process of generating the page begins with the shortcode [download_checkout] which is defined in .\shortcodes.php. The shortcode is a means to execute the function edd_checkout_form() which is defined in .\checkout\template.php.

	if edd_get_cart_contents()
		edd_checkout_cart()
		'edd_before_purchase_form'
		<form>
			'edd_checkout_form_top'
			if ( edd_show_gateways() )
				'edd_payment_mode_select'
			else
				'edd_purchase_form'
			endif
			'edd_checkout_form_bottom'
		</form>
		'edd_after_purchase_form'
	else
		'edd_cart_empty'
	endif

The most important parts from a presentation point of view are the call to edd_checkout_cart() (which displays the list of products, tax, total and update buttons) and the action ‘edd_purchase_form’. The is called either directly from edd_checkout_form() or indirectly from the action ‘edd_payment_mode_select’.

The function edd_checkout_cart() performs the following tasks, the most important of which is the call to execute the template ‘checkout_cart’:

	'edd_before_checkout_cart'
	<form>
		edd_get_template_part( 'checkout_cart' )
	</form>
	'edd_after_checkout_cart'

The template ‘checkout_cart’ is responsible for displaying the cart at the top of the checkout page:

	<table>
		<thead>
			<tr> 'edd_checkout_table_header_first'
				<th>'Item Name', 'Item Price', ‘Actions’
				'edd_checkout_table_header_last'
		<tbody>
			if ( $cart_items )
				'edd_cart_items_before'
				foreach (cart_item)
					<tr>	‘edd_checkout_table_body_first'
						'edd_checkout_table_body_last'

				if( edd_cart_has_fees() )
					foreach(fee)
						<tr>
				endif
				'edd_cart_items_after'
			endif
		<tfoot>
			if has_action( 'edd_cart_footer_buttons' )
				<tr>
					<th>	'edd_cart_footer_buttons'
			endif

			if edd_use_taxes()
				<tr>	'edd_checkout_table_subtotal_first'
					<th>	edd_cart_subtotal()
					'edd_checkout_table_subtotal_last’

				if ! edd_prices_show_tax_on_checkout()
					<tr>	'edd_checkout_table_tax_first'
						<th>	edd_get_cart_tax( false )
						'edd_checkout_table_tax_last'
				endif

			endif

			<tr>	'edd_checkout_table_discount_first'
				<th>	edd_cart_discounts_html()
				'edd_checkout_table_discount_last'

			<tr>	'edd_checkout_table_footer_first'
				<th>	 edd_cart_total()
				'edd_checkout_table_footer_last'
	</table>

So much for the cart. The rest of the checkout form is generated by the action ‘edd_purchase_form’. The action is implemented in .\checkout\template.php and calls the function edd_show_purchase_form().

	'edd_purchase_form_top'

	if edd_can_checkout()

		'edd_purchase_form_before_register_login'

		if show_register_form && !is_user_logged_in() && !login
			'edd_purchase_form_register_fields'
		elseif show_register_form && !is_user_logged_in() && login
			'edd_purchase_form_login_fields'
		endif

		if  !login && is_user_logged_in()|| !show_register_form
			 'edd_purchase_form_after_user_info'
		endif

		'edd_purchase_form_before_cc_form'

		if has_action( 'edd_' . $payment_mode . '_cc_form'
			'edd_' . $payment_mode . '_cc_form'
		else
			'edd_cc_form'
		endif

		'edd_purchase_form_after_cc_form'
	else
		'edd_purchase_form_no_access'
	endif

	'edd_purchase_form_bottom'

Information and Links

Join the fray by commenting, tracking what others have to say, or linking to it from your blog.


Other Posts

Write a Comment

Take a moment to comment and tell us what you think. Some basic HTML is allowed for formatting.

Reader Comments

Be the first to leave a comment!