wc_get_default_shipping_method_for_package()
Choose the default method for a package.
Хуки из функции
Возвращает
Строку
.
Использование
wc_get_default_shipping_method_for_package( $key, $package, $chosen_method );
- $key(int) (обязательный)
- Key of package.
- $package(массив) (обязательный)
- Package data array.
- $chosen_method(строка) (обязательный)
- Chosen method id.
Список изменений
С версии 3.2.0 | Введена. |
Код wc_get_default_shipping_method_for_package() wc get default shipping method for package WC 7.3.0
function wc_get_default_shipping_method_for_package( $key, $package, $chosen_method ) { $rate_keys = array_keys( $package['rates'] ); $default = current( $rate_keys ); $coupons = WC()->cart->get_coupons(); foreach ( $coupons as $coupon ) { if ( $coupon->get_free_shipping() ) { foreach ( $rate_keys as $rate_key ) { if ( 0 === stripos( $rate_key, 'free_shipping' ) ) { $default = $rate_key; break; } } break; } } return apply_filters( 'woocommerce_shipping_chosen_method', $default, $package['rates'], $chosen_method ); }