Skip to content

Instantly share code, notes, and snippets.

@danieliser
Created March 29, 2015 06:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danieliser/35380c1336c4d057f59e to your computer and use it in GitHub Desktop.
Save danieliser/35380c1336c4d057f59e to your computer and use it in GitHub Desktop.
EDD Move User Fields Above Payment Type Selection
remove_action( 'edd_purchase_form', 'edd_show_purchase_form' );
add_action( 'edd_checkout_form_top', 'edden_show_purchase_form_user_fields' );
add_action( 'edd_purchase_form', 'edden_show_purchase_form_payment_fields' );
function edden_show_purchase_form_user_fields() {
if ( edd_can_checkout() ) {
do_action( 'edd_purchase_form_before_register_login' );
$show_register_form = edd_get_option( 'show_register_form', 'none' ) ;
if( ( $show_register_form === 'registration' || ( $show_register_form === 'both' && ! isset( $_GET['login'] ) ) ) && ! is_user_logged_in() ) : ?>
<div id="edd_checkout_login_register">
<?php do_action( 'edd_purchase_form_register_fields' ); ?>
</div>
<?php elseif( ( $show_register_form === 'login' || ( $show_register_form === 'both' && isset( $_GET['login'] ) ) ) && ! is_user_logged_in() ) : ?>
<div id="edd_checkout_login_register">
<?php do_action( 'edd_purchase_form_login_fields' ); ?>
</div>
<?php endif; ?>
<?php if( ( !isset( $_GET['login'] ) && is_user_logged_in() ) || ! isset( $show_register_form ) || 'none' === $show_register_form ) {
do_action( 'edd_purchase_form_after_user_info' );
}
} else {
// Can't checkout
do_action( 'edd_purchase_form_no_access' );
}
}
function edden_show_purchase_form_payment_fields() {
$payment_mode = edd_get_chosen_gateway();
/**
* Hooks in at the top of the purchase form
*
* @since 1.4
*/
do_action( 'edd_purchase_form_top' );
if ( edd_can_checkout() ) {
/**
* Hooks in before Credit Card Form
*
* @since 1.4
*/
do_action( 'edd_purchase_form_before_cc_form' );
if( edd_get_cart_total() > 0 ) {
// Load the credit card form and allow gateways to load their own if they wish
if ( has_action( 'edd_' . $payment_mode . '_cc_form' ) ) {
do_action( 'edd_' . $payment_mode . '_cc_form' );
} else {
do_action( 'edd_cc_form' );
}
}
/**
* Hooks in after Credit Card Form
*
* @since 1.4
*/
do_action( 'edd_purchase_form_after_cc_form' );
} else {
// Can't checkout
do_action( 'edd_purchase_form_no_access' );
}
/**
* Hooks in at the bottom of the purchase form
*
* @since 1.4
*/
do_action( 'edd_purchase_form_bottom' );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment