element->product_requires_wes, "yeswes") == 0) ? true : false;
$productIsContractRequired = (strcasecmp($this->element->product_requires_contract, "yescontract") == 0) ? true : false;
$productIsCriminalRecordRequired = (strcasecmp($this->element->product_requires_criminal_record_doc, "yescriminalrecord") == 0) ? true : false;
$productIsAdultRequired = (strcasecmp($this->element->product_requires_adult, "yesadult") == 0) ? true : false;
$productIsRestrictedForOnlineSale = (strcasecmp($this->element->product_restrict_online_sale, "yesrestrictedonlinesale") == 0) ? true : false;
// Load user data and read them to the required variables
$hikaShopUser = hikaShop_loadUser(true);
$isUserLoggedIn = (is_null($hikaShopUser)) ? false : true;
$userAge = 0;
$isUserAdult = false;
$isUsersPermitValid = false;
$isUsersBirthdateRegistered = false;
$isUsersValidityExpireDateRegistered = false;
if ($isUserLoggedIn) {
// Calculate age of customer
$usersBirthdate = $hikaShopUser->user_date_of_birth;
if(!is_null($usersBirthdate)) {
if(strlen($usersBirthdate) > 0) {
$isUsersBirthdateRegistered = true;
$birthday_timestamp = strtotime($hikaShopUser->user_date_of_birth);
$userAge = date('md', $birthday_timestamp) > date('md') ? date('Y') - date('Y', $birthday_timestamp) - 1 : date('Y') - date('Y', $birthday_timestamp);
if($userAge < 0) {
$userAge = 0; // in case when a future date has been entered for birthdate.
}
if($userAge >= 18) {
$isUserAdult = true;
}
}
}
// Calculate if the user is valid.
$usersValidityExpireDate = $hikaShopUser->user_validity_expire_date;
if(!is_null($usersValidityExpireDate)) {
if(strlen($usersValidityExpireDate) > 0) {
$isUsersValidityExpireDateRegistered = true;
$validity_timestamp = strtotime($hikaShopUser->user_validity_expire_date);
$now_timestamp = strtotime("now");
if($validity_timestamp > $now_timestamp) {
$isUsersPermitValid = true;
}
else {
if($validity_timestamp == $now_timestamp) {
$isUsersPermitValid = true;
}
}
}
}
}
$displayCart = true;
if($productIsWesRequired || $productIsContractRequired || $productIsRestrictedForOnlineSale)
{
$displayCart = false;
}
else if ($productIsCriminalRecordRequired && $isUsersPermitValid == false)
{
$displayCart = false;
}
else if($productIsAdultRequired && $isUserAdult == false)
{
$displayCart = false;
}
$displayNoStockMessage = true;
if($productIsWesRequired || $productIsContractRequired || $productIsRestrictedForOnlineSale)
{
$displayNoStockMessage = false;
}
if($productIsWesRequired || $productIsContractRequired || $productIsCriminalRecordRequired || $productIsAdultRequired || $productIsRestrictedForOnlineSale) {?>