';
if ( edd_get_cart_contents() || edd_cart_has_fees() ) :
edd_checkout_cart(); ?>
';
return ob_get_clean();
}
/**
* Renders the Purchase Form, hooks are provided to add to the purchase form.
* The default Purchase Form rendered displays a list of the enabled payment
* gateways, a user registration form (if enable) and a credit card info form
* if credit cards are enabled
*
* @since 1.4
* @return string
*/
function edd_show_purchase_form() {
$payment_mode = edd_get_chosen_gateway();
/**
* Hooks in at the top of the purchase form.
*
* @since 1.4
*/
do_action( 'edd_purchase_form_top' );
// Maybe load purchase form.
if ( edd_can_checkout() ) {
/**
* Fires before the register/login form.
*
* @since 1.4
*/
do_action( 'edd_purchase_form_before_register_login' );
$show_register_form = edd_get_option( 'show_register_form', 'none' );
if ( ( 'registration' === $show_register_form || ( 'both' === $show_register_form && ! isset( $_GET['login'] ) ) ) && ! is_user_logged_in() ) : ?>
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 the credit card form.
*
* @since 1.4
*/
do_action( 'edd_purchase_form_after_cc_form' );
// Can't checkout.
} else {
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' );
}
add_action( 'edd_purchase_form', 'edd_show_purchase_form' );
/**
* Shows the User Info fields in the Personal Info box, more fields can be added
* via the hooks provided.
*
* @since 1.3.3
* @return void
*/
function edd_user_info_fields() {
$customer = EDD()->session->get( 'customer' );
$customer = wp_parse_args( $customer, array( 'first_name' => '', 'last_name' => '', 'email' => '' ) );
if ( is_user_logged_in() ) {
$user_data = get_userdata( get_current_user_id() );
foreach ( $customer as $key => $field ) {
if ( 'email' === $key && empty( $field ) ) {
$customer[ $key ] = $user_data->user_email;
} elseif ( empty( $field ) ) {
$customer[ $key ] = $user_data->$key;
}
}
}
$customer = array_map( 'sanitize_text_field', $customer );
?>
session->get( 'customer' );
$customer = wp_parse_args( $customer, array(
'address' => array(
'line1' => '',
'line2' => '',
'city' => '',
'zip' => '',
'state' => '',
'country' => '',
),
) );
$customer['address'] = array_map( 'sanitize_text_field', $customer['address'] );
if ( $logged_in ) {
$user_address = edd_get_customer_address();
foreach ( $customer['address'] as $key => $field ) {
if ( empty( $field ) && ! empty( $user_address[ $key ] ) ) {
$customer['address'][ $key ] = $user_address[ $key ];
} else {
$customer['address'][ $key ] = '';
}
}
}
/**
* Filter the billing address details that will be pre-populated on the checkout form..
*
* @since 2.8
*
* @param array $address The customer address.
* @param array $customer The customer data from the session
*/
$customer['address'] = apply_filters( 'edd_checkout_billing_details_address', $customer['address'], $customer );
ob_start(); ?>
';
foreach ( $payment_methods as $key => $option ) {
echo edd_get_payment_image( $key, $option );
}
echo '';
}
add_action( 'edd_payment_mode_top', 'edd_show_payment_icons' );
add_action( 'edd_checkout_form_top', 'edd_show_payment_icons' );
/**
* Renders the Discount Code field which allows users to enter a discount code.
* This field is only displayed if there are any active discounts on the site else
* it's not displayed.
*
* @since 1.2.2
* @return void
*/
function edd_discount_field() {
if ( isset( $_GET['payment-mode'] ) && edd_is_ajax_disabled() ) {
return; // Only show before a payment method has been selected if ajax is disabled
}
if ( ! edd_is_checkout() ) {
return;
}
if ( edd_has_active_discounts() && edd_get_cart_total() ) :
$color = edd_get_button_color_class();
$style = edd_get_option( 'button_style', 'button' ); ?>
order_id ) ) {
$order = edd_get_order_by( 'id', $order_item->order_id );
$cart = edd_get_payment_meta_cart_details( $order->id, true );
$item = $cart[ $item->cart_index ];
}
$ret = apply_filters( 'edd_receipt_show_download_files', $ret, $item_id, $receipt_args, $item );
}
// If the $order_item is an array, get the order item object instead.
if ( is_array( $order_item ) && ! empty( $order_item['order_item_id'] ) ) {
$order_item = edd_get_order_item( $order_item['order_item_id'] );
}
/**
* Modifies whether the receipt should show download files.
*
* @since 3.0
* @param bool $ret True if the download files should be shown.
* @param int $item_id The download ID.
* @param array $receipt_args Args specified in the [edd_receipt] shortcode.
* @param \EDD\Orders\Order_Item $item The order item object.
*/
return apply_filters( 'edd_order_receipt_show_download_files', $ret, $item_id, $receipt_args, $order_item );
}