Adding badges to compare view

  • Posts: 38
  • Thank you received: 0
9 years 5 months ago #227826

-- url of the page with the problem -- : localhost
-- HikaShop version -- : 2.6.1
-- Joomla version -- : 3.4.8
-- PHP version -- : 5.6.8
-- Browser(s) name and version -- : FF43

I have been trying to hack this one together but just can't. I would like to call the badges into the compare view. Could you give me the correct php so that I can drop it into that view.

Many thanks.

Please Log in or Create an account to join the conversation.

  • Posts: 13201
  • Thank you received: 2322
9 years 5 months ago #227855

Hi,

So the code to display the badge is present in the view "product / show_block_img", you have to take it from there and add it in the "product / compare" view.

The default code is:

									if(!empty($this->element->badges))
										$html .= $this->classbadge->placeBadges($this->image, $this->element->badges, '0', '0',false);
You have to adapt it with the correct variables, and add it right after the img html tag.

The following user(s) said Thank You: teamtmedia

Please Log in or Create an account to join the conversation.

  • Posts: 38
  • Thank you received: 0
9 years 5 months ago #227945

I knew it would be there...somewhere but at the end of a day at the code-face I couldn't see the woods for the trees so turned to you guys as I knew you would know exactly where to lift it from. Nice one!

Please Log in or Create an account to join the conversation.

  • Posts: 38
  • Thank you received: 0
9 years 5 months ago #227949

OK. That wasn't as easy as I thought. I'm just not pulling in the data from the field. I know that it is a separate table from the product table so I'm having an issue with the code. To be honest I do feel that this is an omission on this view as it would be logical to compare any relevant deals, discounts, etc when comparing the product. I would, and I'm sure I'm not alone, appreciate the right code to accomplish this.

I imagine that this would be a useful addition to the compare tool (which is an important part of any technical e-commerce solution).

Cheers

Please Log in or Create an account to join the conversation.

  • Posts: 84079
  • Thank you received: 13629
  • MODERATOR
9 years 5 months ago #227966

Hi,

The badges are not loaded in that view so of course you can't just use the placeBadges function there like that.
You first need to load and add the badges to the products.

To do that, you can use that code:
$this->badgeClass->loadBadges($this->element);

Please Log in or Create an account to join the conversation.

Time to create page: 0.082 seconds
Powered by Kunena Forum