関数
RestRouteGuards::deliveryMethodCheck()
Performs validation checks on a selected delivery method and returns a GenericError
instance if validation fails
戻り値 戻り値
ファイル: src/Routing/RestRouteGuards.php
public function deliveryMethodCheck() { return function () { global $usces, $usces_settings; $mes = ''; if (!isset($_POST['offer']['delivery_method']) || (empty($_POST['offer']['delivery_method']) && !\WCUtils::is_zero($_POST['offer']['delivery_method']))) { $mes .= __('chose one from delivery method.', 'usces') . '<br />'; } else { $d_method_index = $usces->get_delivery_method_index((int)$_POST['offer']['delivery_method']); if (0 > $d_method_index) { $mes .= __('chose one from delivery method.', 'usces') . '<br />'; } else { $country = $_SESSION['usces_entry']['delivery']['country']; $WPLANG = get_option('WPLANG'); $wplang = !empty($WPLANG) ? $WPLANG : get_locale(); $locale = empty($wplang) ? 'en' : $wplang; $local_country = array_key_exists($locale, $usces_settings['lungage2country']) ? $usces_settings['lungage2country'][$locale] : 'US'; if ($country == $local_country) { if ($usces->options['delivery_method'][$d_method_index]['intl'] == 1) { $mes .= __('Delivery method is incorrect. Can not specify an international flight.', 'usces') . '<br />'; } } else { if (\WCUtils::is_zero($usces->options['delivery_method'][$d_method_index]['intl'])) { $mes .= __('Delivery method is incorrect. Specify the international flights.', 'usces') . '<br />'; } } } } if (!\WCUtils::is_blank($mes)) { return $this->module->errors->getErrorResponse( GenericErrorStore::USCES_DELIVERY_METHOD_INVALID, [$mes], [$mes] ); } }; }