public function calculate_shipping($package = array())
 {
     if ($this->enabled_in_cart !== 'yes' && is_cart()) {
         return;
     }
     $rates = array();
     $errors = array();
     $shipping_values = $this->edostavka_calculate($package);
     if (!empty($shipping_values)) {
         $chosen_method = null;
         foreach ($shipping_values as $code => $shipping) {
             if (!isset($shipping['result'])) {
                 continue;
             }
             if ($this->replace_shipping_label_door === 'yes' && WC_Edostavka::wc_edostavka_delivery_tariffs_type($code) === 'door') {
                 $name = $this->shipping_label_door;
             } elseif ($this->replace_shipping_label_stock === 'yes' && WC_Edostavka::wc_edostavka_delivery_tariffs_type($code) === 'stock') {
                 $name = $this->shipping_label_stock;
             } else {
                 $name = WC_Edostavka_Connect::get_service_name($code);
             }
             $price = $shipping['result']['price'];
             $label = 'yes' == $this->display_date ? WC_Edostavka_Connect::estimating_delivery(apply_filters('woocommerce_edostavka_label_name', $name), $shipping['result']['deliveryPeriodMax'], $this->additional_time) : $name;
             $cost = $this->fix_format(esc_attr($price));
             $fee = $this->get_fee($this->fix_format($this->fee), $cost);
             array_push($rates, array('id' => $this->id . '_' . $code, 'label' => $label, 'cost' => $cost + $fee));
             $chosen_method = $this->id . '_' . $code;
         }
         $rates = apply_filters('woocommerce_edostavka_shipping_methods', $rates, $package);
         if ($this->autoselect_edostavka_shipping_method === 'yes' && $chosen_method !== null) {
             WC()->session->set('chosen_shipping_methods', array($chosen_method));
         }
         if (sizeof($rates) > 0) {
             foreach ($rates as $rate) {
                 $this->add_rate($rate);
             }
             if (is_cart() && 'yes' == $this->show_notice) {
                 wc_add_notice($this->notice_text, 'notice');
             }
         } else {
             if (is_checkout() && strpos(WC_Edostavka::get_chosen_shipping_method(), $this->id) === 0 && 'yes' == $this->show_error) {
                 wc_add_notice($this->error_text, 'error');
             }
         }
     }
 }