Jump to content

[SOLVED] blockspecial error "undefined index" when VAT not shown


Recommended Posts

I have a bug in my blockspecial module (PS 1.5.6.1, module v. 1.0)

 

If I log-in as a foreign user registered with VAT ID, I correctly see the prices without taxes.

 

By the way, if there are products on offer shown in the blockspecial module, i get the error:

 

Notice: Undefined index: priceWithoutReduction_tax_excl inC:\xampp\htdocs\prestashop\cache\smarty\compile\50\97\54\509754be458c82ea8c05f115388675b1b9c82496.file.blockspecials.tpl.phpon line 79



Notice: Trying to get property of non-object inC:\xampp\htdocs\prestashop\cache\smarty\compile\50\97\54\509754be458c82ea8c05f115388675b1b9c82496.file.blockspecials.tpl.phpon line 79

 

Note that the message is shown inside the special offers products (not visible in f12 console, debug mode activated).

 

If I log out (or if I login as a non-VAT rgistered user) everything works correctly.

My deduction is that the problem is caused by the combination of discounted products and prices shown without taxes.

 

Do someone is able to help?

Edited by vansrv7 (see edit history)
Link to comment
Share on other sites

Hm, ok, open blockspecials.php and see if you have this:

 

$this->smarty->assign(array(
'special' => $special,
'priceWithoutReduction_tax_excl' => Tools::ps_round($special['price_without_reduction'], 2),
'mediumSize' => Image::getSize(ImageType::getFormatedName('medium')),
));
 
In hookRightColumn
Link to comment
Share on other sites

Hi Nemo,

the code exists, by the way, for some reason, the 3rd line was commented (/* ... */).

I removed the comment but I still have an error on the same line:

 

Notice: Undefined index: price_without_reduction in C:\xampp\htdocs\prestashop\modules\blockspecials\blockspecials.php on line 121

 

Now the error is shown even if I'm not logged as a foreign customer (ie. not only for non-vat discounted products). More, if I'm logged in, the old price (without discount) is 0.00

Link to comment
Share on other sites

Did you have someone edit that file?

 

that hooking method should look like

	public function hookRightColumn($params)
	{
		if (Configuration::get('PS_CATALOG_MODE'))
			return;
		
		// We need to create multiple caches because the products are sorted randomly
		$random = date('Ymd').'|'.round(rand(1, max(Configuration::get('BLOCKSPECIALS_NB_CACHES'), 1)));

		if (!Configuration::get('BLOCKSPECIALS_NB_CACHES') || !$this->isCached('blockspecials.tpl', $this->getCacheId('blockspecials|'.$random)))
		{
			if (!($special = Product::getRandomSpecial((int)$params['cookie']->id_lang)) && !Configuration::get('PS_BLOCK_SPECIALS_DISPLAY'))
				return;

			$this->smarty->assign(array(
				'special' => $special,
				'priceWithoutReduction_tax_excl' => Tools::ps_round($special['price_without_reduction'], 2),
				'mediumSize' => Image::getSize(ImageType::getFormatedName('medium')),
			));
		}

		return $this->display(__FILE__, 'blockspecials.tpl', (Configuration::get('BLOCKSPECIALS_NB_CACHES') ? $this->getCacheId('blockspecials|'.$random) : null));
	}
Link to comment
Share on other sites

No, I don't remeber I ever modified that file. By the way, it looks exactly like the one you posted except for the line

 

if (!($special = Product::getRandomSpecial((int)$params['cookie']->id_lang)) && !Configuration::get('PS_BLOCK_SPECIALS_DISPLAY'))

 

that in my case is

 

if (!($special= Product::getPricesDrop((int)$params['cookie']->id_lang,0,5)) && !Configuration::get('PS_BLOCK_SPECIALS_DISPLAY'))

 

If I modify this, I get a new world of error messages

 

Warning: Illegal string offset 'specific_prices' in C:\xampp\htdocs\prestashop\cache\smarty\compile\50\97\54\509754be458c82ea8c05f115388675b1b9c82496.file.blockspecials.tpl.php on line 64

Warning: Illegal string offset 'specific_prices' in C:\xampp\htdocs\prestashop\cache\smarty\compile\50\97\54\509754be458c82ea8c05f115388675b1b9c82496.file.blockspecials.tpl.php on line 65

Warning: Illegal string offset 'reduction_type' in C:\xampp\htdocs\prestashop\cache\smarty\compile\50\97\54\509754be458c82ea8c05f115388675b1b9c82496.file.blockspecials.tpl.php on line 66 - See more at: http://127.0.0.1/prestashop/sherline/index.php?id_product=9&controller=product&id_lang=1#sthash.Y8w8jkJz.dpuf

 

and so on.... (maybe 50-60 messages)

Link to comment
Share on other sites

Ok, solved.

 

Don't know exactly where the problem was, I simply copied blockspecial.php and blockspecial.tpl from downloaded PS installation back to the relative folder in my installation. Now it works.

 

Thank you for your help.

Link to comment
Share on other sites

  • 3 years later...

I'm also facing this notice undefined index problem.

 

"28 Jun 2017 02:12:35","/home2/science/public_html/shop/cache/smarty/compile/f9/fb/48/f9fb48946cee513553c5f40617986411256da877.file.search.tpl.php:
138","(Notice) Undefined index: search_query"

"28 Jun 2017 02:12:35","/home2/science/public_html/shop/cache/smarty/compile/f9/fb/48/f9fb48946cee513553c5f40617986411256da877.file.search.tpl.php:

138","(Notice) Trying to get property of non-object"

 

Please give me any idea to resolve this problem.

Link to comment
Share on other sites

×
×
  • Create New...