Post by Smucka » Mon Jan 17, 2022 9:39 pm

Hello,

I've edited some files that enable me to create a coupon by manufacturer. The code works ok, I can create and delete a coupon without a problem. Also tested with applying coupons in frontend which works flawlessly. The problem I'm having is that when I try to edit the coupon I get a notice:

Code: Select all

Notice: Undefined property: Proxy::getCategory in ...admin/controller/marketing/coupon.php on line 76
I checked what's going on on line 76 in said file, but all I see is:

Code: Select all

		$this->getForm();
Am I missing something?
Thanks!
Last edited by Smucka on Fri Jan 21, 2022 7:46 pm, edited 1 time in total.

Newbie

Posts

Joined
Sat Nov 14, 2020 2:22 am

Post by Johnathan » Mon Jan 17, 2022 11:28 pm

Does the filepath in the error have the word "storage" in it? If so, you have an ocMod affecting the file, which is probably causing the error. Double-check your ocMod extensions that might affect coupons (especially a category-to-coupon mod, based on the error) and try disabling it. That may fix it.

If you can't figure it out and need to find a developer, you can post a request in the OpenCart "Commercial Support" forum, which is checked by a number of OpenCart developers. You can also try checking out the OpenCart "Partners" area.

Image
Image Image Image Image


User avatar
Global Moderator

Posts

Joined
Fri Dec 18, 2009 3:08 am


Post by Smucka » Tue Jan 18, 2022 5:35 pm

The filepath does not include the word "storage" in it, and I'm not using a category-to-coupon mod. I edited the files by hand, including .twig files. I probably forgot to change something that allows coupon editing, I just don't know what exactly.

To try and be a bit clearer, I searched for coupon_category in all files then just copy / pasted and edited the pasted code to "coupon_manufacturer". I also created two tables in my DB.

Thanks.

edit:
Ok so I just re-uploaded coupon.php from \admin\controller\marketing and I can now edit the coupon, but when trying to save the edited coupon I get HTTP error 500. This only happens to coupons that are created "by manufacturer". If I create a coupon by product or category I can edit and save them without a problem.

Newbie

Posts

Joined
Sat Nov 14, 2020 2:22 am

Post by ADD Creative » Tue Jan 18, 2022 6:38 pm

Check your PHP error log for more information on what is causing the 500 error.

www.add-creative.co.uk


Expert Member

Posts

Joined
Sat Jan 14, 2012 1:02 am
Location - United Kingdom

Post by Smucka » Tue Jan 18, 2022 8:18 pm

I'm seeing a notice and a warning

Code: Select all

PHP Notice:  Undefined index: path in .../admin/controller/marketing/coupon.php on line 456
Line 456:

Code: Select all

if (isset($this->request->post['coupon_manufacturer'])) {
	$manufacturer = $this->request->post['coupon_manufacturer'];
} elseif (isset($this->request->get['coupon_id'])) {
	$manufacturer = $this->model_marketing_coupon->getCouponManufacturer($this->request->get['coupon_id']);
} else {
	$manufacturer = array();
}

$this->load->model('catalog/manufacturer');

$data['coupon_manufacturer'] = array();

foreach ($manufacturer as $manufacturer_id) {
	$manufacturer_info = $this->model_catalog_manufacturer->getManufacturer($manufacturer_id);

	if ($manufacturer_info) {
		$data['coupon_manufacturer'][] = array(
			'manufacturer_id' => $manufacturer_info['manufacturer_id'],
  		 	'name'       	  => ($manufacturer_info['path'] ? $manufacturer_info['path'] . ' > ' : '') . $manufacturer_info['name'] // -LINE 456
		);
	}
}
Where can I define the index for line 456?

PHP Warning:

Code: Select all

PHP Warning:  A non-numeric value encountered in .../admin/model/marketing/coupon.php on line 52
line 52:

Code: Select all

		$this->db->query("DELETE FROM " . DB_PREFIX . "coupon_manufacturer WHERE coupon_id = '" . (int)$coupon_id - "'"); // line 52

		if (isset($data['coupon_manufacturer'])) {
			foreach ($data['coupon_manufacturer'] as $manufacturer_id) {
				$this->db->query("INSERT INTO " . DB_PREFIX . "coupon_manufacturer SET coupon_id = '" . (int)$coupon_id . "', manufacturer_id = '" . (int)$manufacturer_id . "'");
			}
		}
Thanks!

Newbie

Posts

Joined
Sat Nov 14, 2020 2:22 am

Post by ADD Creative » Wed Jan 19, 2022 12:08 am

You need to check the PHP or server error log, not the OpenCart one, to find the cause of the 500 error.

As for your notice and a warning. There is no 'path' in manufacturer_info. You have a - and not a . after $coupon_id.

www.add-creative.co.uk


Expert Member

Posts

Joined
Sat Jan 14, 2012 1:02 am
Location - United Kingdom

Post by Smucka » Wed Jan 19, 2022 8:55 pm

Ugh, silly me. I'm running opencart on my subdomain (for testing purposes so I don't accidentaly break the live site) and I think I found the correct error log.

Code: Select all

PHP Fatal error:  Uncaught Exception: Error: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '0' at line 1<br />Error No: 1064<br />0 in .../system/library/db/mysqli.php:40
Stack trace:
#0 .../system/library/db.php(45): DB\MySQLi->query(0)
#1 .../admin/model/marketing/coupon.php(52): DB->query(0)
#2 .../vqmod/vqcache/vq2-system_storage_modification_system_engine_loader.php(259): ModelMarketingCoupon->editCoupon('17', Array)
#3 .../system/engine/proxy.php(47): Loader->{closure}(Array, Array)
#4 .../admin/controller/marketing/coupon.php(55): Proxy->__call('editCoupon', Array)
#5 .../vqmod/vqcache/vq2-syste in .../system/library/db/mysqli.php on line 40
As for the "-" instead of ".", I'm blaming my new keyboard and I made the correction, thanks for pointing it out. And by correcting this, I can now successfully edit the coupon.

I checked the error log again and can't see any new records, so I'm willing to bet that it was just a typo that caused problems. Typical.
Thanks for the help!

edit:
Ok so after a bit of testing I found out that the coupon by manufacturer works for all products / all manufacturers, not just assigned ones. Any tips on where I should look to correct this behaviour?

Newbie

Posts

Joined
Sat Nov 14, 2020 2:22 am

Post by Smucka » Fri Jan 21, 2022 7:45 pm

I've solved the PHP notice problem by combing through the code. It appears I haven't edited all the files neccessary for the coupon to work and forgot to create a few more tables in my DB. The problem I'm facing now is that I can't apply the created manufacturer coupon to any manufacturer. I don't get any error messages.

I'll mark this thread as solved and open up a new one.
Thanks.

Newbie

Posts

Joined
Sat Nov 14, 2020 2:22 am
Who is online

Users browsing this forum: No registered users and 12 guests