Tidy, refactor, and split up methods in checkout class

This commit is contained in:
Mike Jolley 2016-11-25 21:46:34 +00:00
parent 11bb13d613
commit 43d362d107
6 changed files with 731 additions and 661 deletions

File diff suppressed because it is too large Load Diff

View File

@ -111,7 +111,6 @@ class WC_Customer_Data_Store_Session extends WC_Data_Store_WP implements WC_Cust
protected function set_defaults( &$customer ) {
$default = wc_get_customer_default_location();
// Set some defaults if some of our values are still not set.
if ( ! $customer->get_billing_country() ) {
$customer->set_billing_country( $default['country'] );
}
@ -127,6 +126,11 @@ class WC_Customer_Data_Store_Session extends WC_Data_Store_WP implements WC_Cust
if ( ! $customer->get_shipping_state() ) {
$customer->set_shipping_state( $customer->get_billing_state() );
}
if ( ! $customer->get_billing_email() && is_user_logged_in() ) {
$current_user = wp_get_current_user();
$customer->set_billing_email( $current_user->user_email );
}
}
/**

View File

@ -605,6 +605,9 @@ $wc_map_deprecated_filters = array(
'woocommerce_order_get_tax_totals' => 'woocommerce_order_tax_totals',
'woocommerce_get_order_refund_get_amount' => 'woocommerce_refund_amount',
'woocommerce_get_order_refund_get_reason' => 'woocommerce_refund_reason',
'default_checkout_billing_country' => 'default_checkout_country',
'default_checkout_billing_state' => 'default_checkout_state',
'default_checkout_billing_country' => 'default_checkout_postcode',
);
foreach ( $wc_map_deprecated_filters as $new => $old ) {

View File

@ -36,7 +36,7 @@ if ( ! defined( 'ABSPATH' ) ) {
<?php do_action( 'woocommerce_before_checkout_billing_form', $checkout ); ?>
<?php foreach ( $checkout->checkout_fields['billing'] as $key => $field ) : ?>
<?php foreach ( $checkout->get_checkout_fields( 'billing' ) as $key => $field ) : ?>
<?php woocommerce_form_field( $key, $field, $checkout->get_value( $key ) ); ?>
@ -46,7 +46,7 @@ if ( ! defined( 'ABSPATH' ) ) {
<?php if ( ! is_user_logged_in() && $checkout->is_registration_enabled() ) : ?>
<?php if ( $checkout->enable_guest_checkout ) : ?>
<?php if ( ! $checkout->is_registration_required() ) : ?>
<p class="form-row form-row-wide create-account">
<label class="woocommerce-form__label woocommerce-form__label--for-checkbox checkbox">
@ -58,13 +58,13 @@ if ( ! defined( 'ABSPATH' ) ) {
<?php do_action( 'woocommerce_before_checkout_registration_form', $checkout ); ?>
<?php if ( ! empty( $checkout->checkout_fields['account'] ) ) : ?>
<?php if ( $checkout->get_checkout_fields( 'account' ) ) : ?>
<div class="create-account">
<p><?php _e( 'Create an account by entering the information below. If you are a returning customer please login at the top of the page.', 'woocommerce' ); ?></p>
<?php foreach ( $checkout->checkout_fields['account'] as $key => $field ) : ?>
<?php foreach ( $checkout->get_checkout_fields( 'account' ) as $key => $field ) : ?>
<?php woocommerce_form_field( $key, $field, $checkout->get_value( $key ) ); ?>

View File

@ -34,7 +34,7 @@ if ( ! $checkout->is_registration_enabled() && $checkout->is_registration_requir
<form name="checkout" method="post" class="checkout woocommerce-checkout" action="<?php echo esc_url( wc_get_checkout_url() ); ?>" enctype="multipart/form-data">
<?php if ( sizeof( $checkout->checkout_fields ) > 0 ) : ?>
<?php if ( $checkout->get_checkout_fields() ) : ?>
<?php do_action( 'woocommerce_checkout_before_customer_details' ); ?>

View File

@ -34,7 +34,7 @@ if ( ! defined( 'ABSPATH' ) ) {
<?php do_action( 'woocommerce_before_checkout_shipping_form', $checkout ); ?>
<?php foreach ( $checkout->checkout_fields['shipping'] as $key => $field ) : ?>
<?php foreach ( $checkout->get_checkout_fields( 'shipping' ) as $key => $field ) : ?>
<?php woocommerce_form_field( $key, $field, $checkout->get_value( $key ) ); ?>
@ -56,7 +56,7 @@ if ( ! defined( 'ABSPATH' ) ) {
<?php endif; ?>
<?php foreach ( $checkout->checkout_fields['order'] as $key => $field ) : ?>
<?php foreach ( $checkout->get_checkout_fields( 'order' ) as $key => $field ) : ?>
<?php woocommerce_form_field( $key, $field, $checkout->get_value( $key ) ); ?>