Page 1 of 1

Fixing Errors 4.1.0.3

Posted: Sat Jul 05, 2025 12:16 am
by gunownergear
Hello,
I have a couple of errors that occur every day and was wanting to see if you guys know how to fix them.
Using OC version 4.1.0.3
PHP is 8.3.22
Error 1
2025-06-19 23:08:43 - PHP Warning: Undefined array key "comment" in /home/gunowner/public_html/catalog/model/account/returns.php on line 44
Line 43

Code: Select all

public function addReturn(array $data): int {
Line 44

Code: Select all

$this->db->query("INSERT INTO `" . DB_PREFIX . "return` SET `order_id` = '" . (int)$data['order_id'] . "', `product_id` = '" . (int)$data['product_id'] . "', `customer_id` = '" . (int)$this->customer->getId() . "', `firstname` = '" . $this->db->escape($data['firstname']) . "', `lastname` = '" . $this->db->escape($data['lastname']) . "', `email` = '" . $this->db->escape($data['email']) . "', `telephone` = '" . $this->db->escape($data['telephone']) . "', `product` = '" . $this->db->escape($data['product']) . "', `model` = '" . $this->db->escape($data['model']) . "', `quantity` = '" . (int)$data['quantity'] . "', `opened` = '" . (int)$data['opened'] . "', `return_reason_id` = '" . (int)$data['return_reason_id'] . "', `return_status_id` = '" . (int)$this->config->get('config_return_status_id') . "', `comment` = '" . $this->db->escape($data['comment']) . "', `date_ordered` = '" . $this->db->escape($data['date_ordered']) . "', `date_added` = NOW(), `date_modified` = NOW()");
Thanks,
Dan

Re: Fixing Errors 4.1.0.3

Posted: Sat Jul 05, 2025 12:42 am
by khnaz35

Code: Select all

	public function addReturn(array $data): int {
		$this->db->query("INSERT INTO `" . DB_PREFIX . "return` SET `order_id` = '" . (int)$data['order_id'] . "', `product_id` = '" . (int)$data['product_id'] . "', `customer_id` = '" . (int)$this->customer->getId() . "', `firstname` = '" . $this->db->escape($data['firstname']) . "', `lastname` = '" . $this->db->escape($data['lastname']) . "', `email` = '" . $this->db->escape($data['email']) . "', `telephone` = '" . $this->db->escape($data['telephone']) . "', `product` = '" . $this->db->escape($data['product']) . "', `model` = '" . $this->db->escape($data['model']) . "', `quantity` = '" . (int)$data['quantity'] . "', `opened` = '" . (int)$data['opened'] . "', `return_reason_id` = '" . (int)$data['return_reason_id'] . "', `return_status_id` = '" . (int)$this->config->get('config_return_status_id') . "', `comment` = '" . $this->db->escape($data['comment'] ?? '') . "', `date_ordered` = '" . $this->db->escape($data['date_ordered']) . "', `date_added` = NOW(), `date_modified` = NOW()");

		return $this->db->getLastId();
	}

Re: Fixing Errors 4.1.0.3

Posted: Sat Jul 05, 2025 4:26 am
by gunownergear
Hi,
Did you fix the code?
The last part of that
return $this->db->getLastId();
}
is already in there but it is on lines 46 and 47

Re: Fixing Errors 4.1.0.3

Posted: Sat Jul 05, 2025 11:15 am
by khnaz35
Yes, replace the full function.