I am trying to set conditions for tax on discount according to customer's country by checking the address_id when he logged in. It is partially working on the whole site except the homepage in which has a module named pavhomebuilder and the "Latest Products". This module displays 5 categories with 5 products each of them through from the template lexus_micmart. I don't know why says that $zone variable are not exist. Anyone know why is thit happening?
OpenCart Version: 2.0.3.1
catalog\model\catalog\product.php:
Code: Select all
public function getZoneFromCustomer($user_id)
{
$customer_zone = array();
$sql = "SELECT country_id FROM ". DB_PREFIX ."address WHERE address_id = (SELECT address_id from " . DB_PREFIX . "customer where customer_id = '".$user_id."')";
$query = $this->db->query($sql);
foreach ($query->rows as $result) {
$customer_zone = $result['country_id'];
}
return $customer_zone;
}
Code: Select all
if ($this->customer->isLogged()) {
$data['zone'] = $this->model_catalog_product->getZoneFromCustomer($this->customer->getId());
} else {
$data['zone']='';
}
Code: Select all
if ($this->customer->isLogged()) {
$data['zone'] = $this->model_catalog_product->getZoneFromCustomer($this->customer->getId());
} else {
$data['zone']='';
}
Code: Select all
if($zone == '84'){
//$discount_price = $discount_price / 1.24;
}