Skip to content

Commit

Permalink
Some more clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
khanrn committed Apr 26, 2018
1 parent d745849 commit 6714d47
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions includes/class-wc-checkout.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ public function __get( $key ) {
if ( in_array( $key, array( 'posted', 'shipping_method', 'payment_method' ), true ) && empty( $this->legacy_posted_data ) ) {
$this->legacy_posted_data = $this->get_posted_data();
}

switch ( $key ) {
case 'enable_signup':
return $this->is_registration_enabled();
Expand Down Expand Up @@ -387,6 +388,7 @@ public function create_order_line_items( &$order, $cart ) {
'taxes' => $values['line_tax_data'],
)
);

if ( $product ) {
$item->set_props(
array(
Expand All @@ -397,6 +399,7 @@ public function create_order_line_items( &$order, $cart ) {
)
);
}

$item->set_backorder_meta();

/**
Expand Down Expand Up @@ -569,9 +572,11 @@ protected function maybe_skip_fieldset( $fieldset_key, $data ) {
if ( 'shipping' === $fieldset_key && ( ! $data['ship_to_different_address'] || ! WC()->cart->needs_shipping_address() ) ) {
return true;
}

if ( 'account' === $fieldset_key && ( is_user_logged_in() || ( ! $this->is_registration_required() && empty( $data['createaccount'] ) ) ) ) {
return true;
}

return false;
}

Expand All @@ -596,6 +601,7 @@ public function get_posted_data() {
$skipped[] = $fieldset_key;
continue;
}

foreach ( $fieldset as $key => $field ) {
$type = sanitize_title( isset( $field['type'] ) ? $field['type'] : 'text' );

Expand Down Expand Up @@ -642,6 +648,7 @@ protected function validate_posted_data( &$data, &$errors ) {
if ( $this->maybe_skip_fieldset( $fieldset_key, $data ) ) {
continue;
}

foreach ( $fieldset as $key => $field ) {
if ( ! isset( $data[ $key ] ) ) {
continue;
Expand Down Expand Up @@ -778,6 +785,7 @@ protected function set_customer_address_fields( $field, $key, $data ) {
WC()->customer->{"set_billing_{$field}"}( $data[ "billing_{$field}" ] );
WC()->customer->{"set_shipping_{$field}"}( $data[ "billing_{$field}" ] );
}

if ( isset( $data[ "shipping_{$field}" ] ) ) {
WC()->customer->{"set_shipping_{$field}"}( $data[ "shipping_{$field}" ] );
}
Expand Down

0 comments on commit 6714d47

Please sign in to comment.