本文整理汇总了PHP中Countries::isUEbyId方法的典型用法代码示例。如果您正苦于以下问题:PHP Countries::isUEbyId方法的具体用法?PHP Countries::isUEbyId怎么用?PHP Countries::isUEbyId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Countries
的用法示例。
在下文中一共展示了Countries::isUEbyId方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isValid
public function isValid($value, $context = null)
{
if (!empty($value)) {
$this->vat = $value;
$countryid = intval($context['country_id']);
if ($countryid == 0) {
$this->_error(self::ISNOTCOUNTRYID);
return false;
}
$country = Countries::find($context['country_id']);
if (!empty($country->code)) {
$this->countryCode = $country->code;
} else {
return false;
}
if (Countries::isITbyId($countryid)) {
if (!is_numeric($value) || strlen($value) != 11) {
$this->_error(self::INVALIDVAT);
return false;
}
} elseif (Countries::isUEbyId($countryid)) {
return $this->eu_check();
}
}
return true;
}
示例2: isVATFree
/**
* Check if the customer is subject to EU-VAT
* TODO: add support for multiple invoicing addresses
*
* @param integer $id
* @return boolean
* @throws Exception
*/
public static function isVATFree($id)
{
if (!is_numeric($id)) {
throw new Exception('Customer Id paramenter is mandatory');
}
$customer = self::getAllInfo($id);
// tax free also means vat free
if (!empty($customer['taxfree']) && $customer['taxfree']) {
return true;
}
$Addresses = Addresses::findOneByUserId($id);
if (!isset($Addresses->country_id) || !is_numeric($Addresses->country_id)) {
return false;
}
if (empty($customer['vat'])) {
/*
* Private
*/
//* EU country, VAT ok
return !Countries::isUEbyId($Addresses->country_id);
} else {
/*
* Company
*/
//* TODO: 82 is Italy. This should not be hardcoded here.
return $Addresses->country_id != 82 ? true : false;
}
}