remove legacy code in shipping

This commit is contained in:
Seghir Nadir 2021-03-22 15:47:39 +01:00
parent 46d032d561
commit 53da9b9b86
No known key found for this signature in database
GPG Key ID: 65750D713E9C2DC0
1 changed files with 1 additions and 12 deletions

View File

@ -411,23 +411,12 @@ function wc_get_chosen_shipping_method_for_package( $key, $package ) {
$chosen_method = isset( $chosen_methods[ $key ] ) ? $chosen_methods[ $key ] : false;
$changed = wc_shipping_methods_have_changed( $key, $package );
// This is deprecated but here for BW compat. TODO: Remove in 4.0.0.
$method_counts = WC()->session->get( 'shipping_method_counts' );
if ( ! empty( $method_counts[ $key ] ) ) {
$method_count = absint( $method_counts[ $key ] );
} else {
$method_count = 0;
}
// If not set, not available, or available methods have changed, set to the DEFAULT option.
if ( ! $chosen_method || $changed || ! isset( $package['rates'][ $chosen_method ] ) || count( $package['rates'] ) !== $method_count ) {
if ( ! $chosen_method || $changed || ! isset( $package['rates'][ $chosen_method ] ) ) {
$chosen_method = wc_get_default_shipping_method_for_package( $key, $package, $chosen_method );
$chosen_methods[ $key ] = $chosen_method;
$method_counts[ $key ] = count( $package['rates'] );
WC()->session->set( 'chosen_shipping_methods', $chosen_methods );
WC()->session->set( 'shipping_method_counts', $method_counts );
do_action( 'woocommerce_shipping_method_chosen', $chosen_method );
}