Post by Estorakos » Tue Mar 23, 2021 10:23 pm

Hello,
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;
	}
catalog\controller\product.php

Code: Select all

if ($this->customer->isLogged()) {
	$data['zone'] = $this->model_catalog_product->getZoneFromCustomer($this->customer->getId()); 
} else {
	$data['zone']=''; 
	}
catalog\controller\category.php:

Code: Select all

if ($this->customer->isLogged()) {
	$data['zone'] = $this->model_catalog_product->getZoneFromCustomer($this->customer->getId()); 
} else {
	$data['zone']=''; 
	}
catalog\view\theme\lexus_micmart\template\common\product\default.tpl

Code: Select all

 if($zone == '84'){
	//$discount_price = $discount_price / 1.24;
     }

Newbie

Posts

Joined
Tue Mar 23, 2021 9:50 pm

Post by straightlight » Fri Mar 26, 2021 2:09 am

Replicated post as a new user.

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON
Who is online

Users browsing this forum: No registered users and 7 guests