当前位置: 首页>>代码示例>>PHP>>正文


PHP Data::isZipCodeOptional方法代码示例

本文整理汇总了PHP中Magento\Directory\Helper\Data::isZipCodeOptional方法的典型用法代码示例。如果您正苦于以下问题:PHP Data::isZipCodeOptional方法的具体用法?PHP Data::isZipCodeOptional怎么用?PHP Data::isZipCodeOptional使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Magento\Directory\Helper\Data的用法示例。


在下文中一共展示了Data::isZipCodeOptional方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: isZipCodeRequired

 /**
  * Determine whether zip-code is required for the country of destination
  *
  * @param string|null $countryId
  * @return bool
  */
 public function isZipCodeRequired($countryId = null)
 {
     if ($countryId != null) {
         return !$this->_directoryData->isZipCodeOptional($countryId);
     }
     return true;
 }
开发者ID:Coplex,项目名称:magento2,代码行数:13,代码来源:AbstractCarrierOnline.php

示例2: toOptionArray

 /**
  * Convert collection items to select options array
  *
  * @param string|boolean $emptyLabel
  * @return array
  */
 public function toOptionArray($emptyLabel = ' ')
 {
     $options = $this->_toOptionArray('country_id', 'name', ['title' => 'iso2_code']);
     $sort = [];
     foreach ($options as $data) {
         $name = (string) $this->_localeLists->getCountryTranslation($data['value']);
         if (!empty($name)) {
             $sort[$name] = $data['value'];
         }
     }
     $this->_arrayUtils->ksortMultibyte($sort, $this->_localeResolver->getLocale());
     foreach (array_reverse($this->_foregroundCountries) as $foregroundCountry) {
         $name = array_search($foregroundCountry, $sort);
         unset($sort[$name]);
         $sort = [$name => $foregroundCountry] + $sort;
     }
     $options = [];
     foreach ($sort as $label => $value) {
         $option = ['value' => $value, 'label' => $label];
         if ($this->helperData->isRegionRequired($value)) {
             $option['is_region_required'] = true;
         }
         if ($this->helperData->isZipCodeOptional($value)) {
             $option['is_zipcode_optional'] = true;
         }
         $options[] = $option;
     }
     if (count($options) > 0 && $emptyLabel !== false) {
         array_unshift($options, ['value' => '', 'label' => $emptyLabel]);
     }
     return $options;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:38,代码来源:Collection.php

示例3: validateValue

 /**
  * Validate postal/zip code
  * Return true and skip validation if country zip code is optional
  *
  * @param array|null|string $value
  * @return array|bool
  */
 public function validateValue($value)
 {
     $attribute = $this->getAttribute();
     $label = __($attribute->getStoreLabel());
     $countryId = $this->getExtractedData('country_id');
     if ($this->directoryHelper->isZipCodeOptional($countryId)) {
         return true;
     }
     $errors = [];
     if (empty($value) && $value !== '0') {
         $errors[] = __('"%1" is a required value.', $label);
     }
     if (count($errors) == 0) {
         return true;
     }
     return $errors;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:24,代码来源:Postcode.php

示例4: initAddressForm

 /**
  * @param AddressInterface $address
  * @return $this
  */
 public function initAddressForm(AddressInterface $address)
 {
     $form = $this->initForm()->getForm();
     $postcode = $form->getElement('postcode');
     if ($postcode) {
         $postcode->removeClass('required-entry')->setRequired(!$this->_directoryHelper->isZipCodeOptional($address->getCountryId()));
     }
     $form->addValues($this->addressMapper->toFlatArray($address))->setHtmlIdPrefix("_item{$address->getId()}")->setFieldNameSuffix('address[' . $address->getId() . ']');
     $this->addValuesToNamePrefixElement($address->getPrefix())->addValuesToNameSuffixElement($address->getSuffix());
     return $this;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:15,代码来源:Addresses.php

示例5: isValid

 /**
  * Check if postcode is valid
  *
  * @param string $countryId
  * @param string $postcode
  * @return bool
  */
 public function isValid($countryId, $postcode)
 {
     return $this->directoryHelper->isZipCodeOptional($countryId) || !empty($postcode);
 }
开发者ID:Zash22,项目名称:magento,代码行数:11,代码来源:Postcode.php


注:本文中的Magento\Directory\Helper\Data::isZipCodeOptional方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。