Post by gunownergear » Sat Jul 05, 2025 12:16 am

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
Last edited by khnaz35 on Sat Jul 05, 2025 12:41 am, edited 1 time in total.
Reason: Stick to one error one thread

Newbie
Online

Posts

Joined
Sun Mar 16, 2025 7:06 am

Post by khnaz35 » Sat Jul 05, 2025 12:42 am

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();
	}

Got an urgent question that’s keeping you up at night? There might just be a magical inbox ready to help: khnaz35@gmail.com
Enjoy nature ;) :) :-*


User avatar
Active Member

Posts

Joined
Mon Aug 27, 2018 11:30 pm
Location - Malaysia

Post by gunownergear » Sat Jul 05, 2025 4:26 am

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

Newbie
Online

Posts

Joined
Sun Mar 16, 2025 7:06 am

Post by khnaz35 » Sat Jul 05, 2025 11:15 am

Yes, replace the full function.

Got an urgent question that’s keeping you up at night? There might just be a magical inbox ready to help: khnaz35@gmail.com
Enjoy nature ;) :) :-*


User avatar
Active Member

Posts

Joined
Mon Aug 27, 2018 11:30 pm
Location - Malaysia
Who is online

Users browsing this forum: jhonnmick and 11 guests