関数
RestRouteGuards::deliveryMethodCheck()
GenericError
instance if validation fails戻り値 戻り値
ファイル: src/Routing/RestRouteGuards.php
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 | 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 ] ); } }; } |