本文整理匯總了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;
}
}