Update shipping code to see if full address has been entered before showing no shipping notice
Fixes #16757
This commit is contained in:
parent
0337293e39
commit
a7b2ae8661
|
@ -247,7 +247,17 @@ jQuery( function( $ ) {
|
|||
s_postcode = postcode,
|
||||
s_city = city,
|
||||
s_address = address,
|
||||
s_address_2 = address_2;
|
||||
s_address_2 = address_2,
|
||||
$required_inputs = $( wc_checkout_form.$checkout_form ).find( '.address-field.validate-required:visible' ),
|
||||
has_full_address = true;
|
||||
|
||||
if ( $required_inputs.length ) {
|
||||
$required_inputs.each( function() {
|
||||
if ( $( this ).find( ':input' ).val() === '' ) {
|
||||
has_full_address = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if ( $( '#ship-to-different-address' ).find( 'input' ).is( ':checked' ) ) {
|
||||
s_country = $( '#shipping_country' ).val();
|
||||
|
@ -259,21 +269,22 @@ jQuery( function( $ ) {
|
|||
}
|
||||
|
||||
var data = {
|
||||
security: wc_checkout_params.update_order_review_nonce,
|
||||
payment_method: wc_checkout_form.get_payment_method(),
|
||||
country: country,
|
||||
state: state,
|
||||
postcode: postcode,
|
||||
city: city,
|
||||
address: address,
|
||||
address_2: address_2,
|
||||
s_country: s_country,
|
||||
s_state: s_state,
|
||||
s_postcode: s_postcode,
|
||||
s_city: s_city,
|
||||
s_address: s_address,
|
||||
s_address_2: s_address_2,
|
||||
post_data: $( 'form.checkout' ).serialize()
|
||||
security : wc_checkout_params.update_order_review_nonce,
|
||||
payment_method : wc_checkout_form.get_payment_method(),
|
||||
country : country,
|
||||
state : state,
|
||||
postcode : postcode,
|
||||
city : city,
|
||||
address : address,
|
||||
address_2 : address_2,
|
||||
s_country : s_country,
|
||||
s_state : s_state,
|
||||
s_postcode : s_postcode,
|
||||
s_city : s_city,
|
||||
s_address : s_address,
|
||||
s_address_2 : s_address_2,
|
||||
has_full_address: has_full_address,
|
||||
post_data : $( 'form.checkout' ).serialize()
|
||||
};
|
||||
|
||||
if ( false !== args.update_shipping_method ) {
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -301,9 +301,6 @@ class WC_AJAX {
|
|||
'shipping_address_1' => isset( $_POST['address'] ) ? $_POST['address'] : null,
|
||||
'shipping_address_2' => isset( $_POST['address_2'] ) ? $_POST['address_2'] : null,
|
||||
) );
|
||||
if ( ! empty( $_POST['country'] ) ) {
|
||||
WC()->customer->set_calculated_shipping( true );
|
||||
}
|
||||
} else {
|
||||
WC()->customer->set_props( array(
|
||||
'shipping_country' => isset( $_POST['s_country'] ) ? $_POST['s_country'] : null,
|
||||
|
@ -313,9 +310,12 @@ class WC_AJAX {
|
|||
'shipping_address_1' => isset( $_POST['s_address'] ) ? $_POST['s_address'] : null,
|
||||
'shipping_address_2' => isset( $_POST['s_address_2'] ) ? $_POST['s_address_2'] : null,
|
||||
) );
|
||||
if ( ! empty( $_POST['s_country'] ) ) {
|
||||
WC()->customer->set_calculated_shipping( true );
|
||||
}
|
||||
}
|
||||
|
||||
if ( wc_string_to_bool( $_POST['has_full_address'] ) ) {
|
||||
WC()->customer->set_calculated_shipping( true );
|
||||
} else {
|
||||
WC()->customer->set_calculated_shipping( false );
|
||||
}
|
||||
|
||||
WC()->customer->save();
|
||||
|
|
|
@ -44,10 +44,10 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||
printf( '%3$s <input type="hidden" name="shipping_method[%1$d]" data-index="%1$d" id="shipping_method_%1$d" value="%2$s" class="shipping_method" />', $index, esc_attr( $method->id ), wc_cart_totals_shipping_method_label( $method ) );
|
||||
do_action( 'woocommerce_after_shipping_rate', $method, $index );
|
||||
?>
|
||||
<?php elseif ( ! WC()->customer->has_calculated_shipping() ) : ?>
|
||||
<?php echo wpautop( __( 'Shipping costs will be calculated once you have provided your address.', 'woocommerce' ) ); ?>
|
||||
<?php else : ?>
|
||||
<?php echo apply_filters( is_cart() ? 'woocommerce_cart_no_shipping_available_html' : 'woocommerce_no_shipping_available_html', wpautop( __( 'There are no shipping methods available. Please double check your address, or contact us if you need any help.', 'woocommerce' ) ) ); ?>
|
||||
<?php elseif ( WC()->customer->has_calculated_shipping() ) : ?>
|
||||
<?php echo apply_filters( is_cart() ? 'woocommerce_cart_no_shipping_available_html' : 'woocommerce_no_shipping_available_html', wpautop( __( 'There are no shipping methods available. Please ensure that your address has been entered correctly, or contact us if you need any help.', 'woocommerce' ) ) ); ?>
|
||||
<?php elseif ( ! is_cart() ) : ?>
|
||||
<?php echo wpautop( __( 'Enter your full address to see shipping costs.', 'woocommerce' ) ); ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ( $show_package_details ) : ?>
|
||||
|
|
Loading…
Reference in New Issue