Я тестирую, чтобы добавить функциональность одной поставки плагина, но моя новая конфигурация не остается активной.Можете ли вы посмотреть и помочь мне с этим кодом?
Когда я активирую этот код и в кассе меняю почтовый код, задержка меняется на 1 секунду и после ничего.
add_filter( 'iconic_wds_min_delivery_date','iconic_change_min_delivery_date4', 10, 2 );
function iconic_change_min_delivery_date4( $min123 ) {
$chosen_shipping = $order ? iconic_get_shipping_methods( $order ) : iconic_get_selected_shipping_method();
if ( ! $chosen_shipping ) {
return $min123;
}
if ( $chosen_shipping === 'flat_rate:11' ) {
$days_to_add = 4;
return array(
'days_to_add' => $days_to_add,
'timestamp' => strtotime( "+" . $days_to_add . " day", current_time( 'timestamp' ) ),
);
}
if ( $chosen_shipping === 'flat_rate:1' ) {
$hours_to_add = 360;
// This filter returns an array containing the days to add and a timestamp.
return array(
'hours_to_add' => $hours_to_add,
'timestamp' => strtotime( "+" . $hours_to_add . " hour", current_time( 'timestamp' ) ),
);
}
}
/**
* Get order shipping method.
*
* @param WC_Order $order
*
* @return bool|string
*/
function iconic_get_order_shipping_method( $order ) {
$chosen_methods = $order->get_shipping_methods();
if ( empty( $chosen_methods ) ) {
return false;
}
$chosen_shipping = array_shift( $chosen_methods );
return sprintf( '%s:%s', $chosen_shipping->get_method_id(), $chosen_shipping->get_instance_id() );
}
/**
* Get selected shipping method.
*
* @return string|bool
*/
function iconic_get_selected_shipping_method() {
if ( is_admin() ) {
return false;
}
$chosen_methods = WC()->session->get( 'chosen_shipping_methods' );
if ( empty( $chosen_methods ) ) {
return false;
}
return $chosen_methods[0];
}