Show multiple badges in top right corner – Determined

  • Posts: 410
  • Thank you received: 15
6 years 11 months ago #267952

-- HikaShop version -- : 3.0.1

Hi I want to add several badges in the top right corner but only one is displayed. Can some badges appear in this area?

I found out how to make new positions. It will not be bad to make several positions in a corner.

Last edit: 6 years 11 months ago by neo191987.

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

  • Posts: 26000
  • Thank you received: 4004
  • MODERATOR
6 years 11 months ago #267987

Hello,

If you place several badges in the same place, you could have some "overlap" issues, one badge can be hover another and you might not see it.
But there is nothing in the badge system which would block you to have several badges for the same position.

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

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

  • Posts: 38
  • Thank you received: 1
6 years 7 months ago #278400

Hi,

I found same issue, and it is not only visibiity issue.

I have two categories (New and Action for example) and two assigned badges. If I assign product to one of these categories,
one badge is displayed correctly, if to both again only one badge is displayed. If changed position of one badge, both are displayed.

Try this on demo, just assign any of products to New products and Discount 10%.

Is there solution for this?

thanks

Pavel

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

  • Posts: 38
  • Thank you received: 1
6 years 7 months ago #278401

Hi again,

seems the problem is in hikashopBadgeClass::placeBadges - for each position only one badge (with lowest ordering) is diaplyed.

Pavel

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

  • Posts: 410
  • Thank you received: 15
6 years 7 months ago #278402

Through modification can add many items. Let's ask developers to add more positions so they do not need to permanently modify this file after every update.

administrator/components/com_hikashop/classes/badge.php

replace line 217 - 232

if($position == 'topleft' && ($position1 == 0 || $badge->badge_ordering < $position1)) {
				$html .= '<div class="hikashop_badge_topleft_div" style="' . $styletopleft . '">' . $imageDisplayed . '</div>';
				$position1 = $badge->badge_ordering;
			}
			elseif($position == 'topleft' && ($position2 == 0 || $badge->badge_ordering < $position2)) {
				$html .= '<div class="hikashop_badge_topleft_div" style="' . $styletopleft . '">' . $imageDisplayed . '</div>';
				$position1 = $badge->badge_ordering;
			}
			elseif($position == 'topleft' && ($position3 == 0 || $badge->badge_ordering < $position3)) {
				$html .= '<div class="hikashop_badge_topleft_div" style="' . $styletopleft . '">' . $imageDisplayed . '</div>';
				$position1 = $badge->badge_ordering;
			}
			elseif($position == 'topleft' && ($position4 == 0 || $badge->badge_ordering < $position4)) {
				$html .= '<div class="hikashop_badge_topleft_div" style="' . $styletopleft . '">' . $imageDisplayed . '</div>';
				$position1 = $badge->badge_ordering;
			}
			elseif($position == 'topleft' && ($position5 == 0 || $badge->badge_ordering < $position5)) {
				$html .= '<div class="hikashop_badge_topleft_div" style="' . $styletopleft . '">' . $imageDisplayed . '</div>';
				$position1 = $badge->badge_ordering;
			}
			elseif($position == 'topright' && ($position6 == 0 || $badge->badge_ordering < $position6)) {
				$html .= '<div class="hikashop_badge_topright_div" style="' . $styletopright . '">' . $imageDisplayed . '</div>';
				$position2 = $badge->badge_ordering;
			}
			elseif($position == 'topright' && ($position7 == 0 || $badge->badge_ordering < $position7)) {
				$html .= '<div class="hikashop_badge_topright_div" style="' . $styletopright . '">' . $imageDisplayed . '</div>';
				$position2 = $badge->badge_ordering;
			}
			elseif($position == 'topright' && ($position8 == 0 || $badge->badge_ordering < $position8)) {
				$html .= '<div class="hikashop_badge_topright_div" style="' . $styletopright . '">' . $imageDisplayed . '</div>';
				$position2 = $badge->badge_ordering;
			}
			elseif($position == 'topright' && ($position9 == 0 || $badge->badge_ordering < $position9)) {
				$html .= '<div class="hikashop_badge_topright_div" style="' . $styletopright . '">' . $imageDisplayed . '</div>';
				$position2 = $badge->badge_ordering;
			}
			elseif($position == 'topright' && ($position10 == 0 || $badge->badge_ordering < $position10)) {
				$html .= '<div class="hikashop_badge_topright_div" style="' . $styletopright . '">' . $imageDisplayed . '</div>';
				$position2 = $badge->badge_ordering;
			}
			elseif($position == 'bottomright' && ($position11 == 0 || $badge->badge_ordering < $position11)) {
				$html .= '<div class="hikashop_badge_bottomright_div" style="' . $stylebottomright . '">' . $imageDisplayed . '</div>';
				$position3 = $badge->badge_ordering;
			}
			elseif($position == 'bottomright' && ($position12 == 0 || $badge->badge_ordering < $position12)) {
				$html .= '<div class="hikashop_badge_bottomright_div" style="' . $stylebottomright . '">' . $imageDisplayed . '</div>';
				$position3 = $badge->badge_ordering;
			}
			elseif($position == 'bottomright' && ($position13 == 0 || $badge->badge_ordering < $position13)) {
				$html .= '<div class="hikashop_badge_bottomright_div" style="' . $stylebottomright . '">' . $imageDisplayed . '</div>';
				$position3 = $badge->badge_ordering;
			}
			elseif($position == 'bottomright' && ($position14 == 0 || $badge->badge_ordering < $position14)) {
				$html .= '<div class="hikashop_badge_bottomright_div" style="' . $stylebottomright . '">' . $imageDisplayed . '</div>';
				$position3 = $badge->badge_ordering;
			}
			elseif($position == 'bottomright' && ($position15 == 0 || $badge->badge_ordering < $position15)) {
				$html .= '<div class="hikashop_badge_bottomright_div" style="' . $stylebottomright . '">' . $imageDisplayed . '</div>';
				$position3 = $badge->badge_ordering;
			}
			elseif($position == 'bottomleft' && ($position16 == 0 || $badge->badge_ordering < $position16)) {
				$html .= '<div class="hikashop_badge_bottomleft_div" style="' . $stylebottomleft . '">' . $imageDisplayed . '</div>';
				$position4 = $badge->badge_ordering;
			}
			elseif($position == 'bottomleft' && ($position17 == 0 || $badge->badge_ordering < $position17)) {
				$html .= '<div class="hikashop_badge_bottomleft_div" style="' . $stylebottomleft . '">' . $imageDisplayed . '</div>';
				$position4 = $badge->badge_ordering;
			}
			elseif($position == 'bottomleft' && ($position18 == 0 || $badge->badge_ordering < $position18)) {
				$html .= '<div class="hikashop_badge_bottomleft_div" style="' . $stylebottomleft . '">' . $imageDisplayed . '</div>';
				$position4 = $badge->badge_ordering;
			}
			elseif($position == 'bottomleft' && ($position19 == 0 || $badge->badge_ordering < $position19)) {
				$html .= '<div class="hikashop_badge_bottomleft_div" style="' . $stylebottomleft . '">' . $imageDisplayed . '</div>';
				$position4 = $badge->badge_ordering;
			}
			elseif($position == 'bottomleft' && ($position20 == 0 || $badge->badge_ordering < $position20)) {
				$html .= '<div class="hikashop_badge_bottomleft_div" style="' . $stylebottomleft . '">' . $imageDisplayed . '</div>';
				$position4 = $badge->badge_ordering;
			}

Last edit: 6 years 7 months ago by neo191987.

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

  • Posts: 410
  • Thank you received: 15
6 years 7 months ago #278403

That must be the result

Attachments:

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

  • Posts: 38
  • Thank you received: 1
6 years 7 months ago #278405

imho multiple badges in position should be better, even with all the settings provided by Hikashop, very tricky.

Simpler solution is to override views (product/show_block_img.php and product/listing_img_title.php) and use own placeBadges.
As I do not need to care abut offset settings, I simplified the function a lot and used custom CSS.

Pavel

The following user(s) said Thank You: Jerome

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

  • Posts: 26000
  • Thank you received: 4004
  • MODERATOR
6 years 7 months ago #278440

Hello,

I agree with n3t ; and regarding your needs, it might want to use a product custom field to store the data of the "badges" instead of using the badge system.

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

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

  • Posts: 410
  • Thank you received: 15
6 years 7 months ago #278468

Jerome wrote: Hello,

I agree with n3t ; and regarding your needs, it might want to use a product custom field to store the data of the "badges" instead of using the badge system.

Regards,


Hi, can you explain in detail how it works. It's really annoying to change this file every time.

Last edit: 6 years 7 months ago by neo191987.

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

  • Posts: 38
  • Thank you received: 1
6 years 7 months ago #278471

There are few ways, how to achieve this, I solve it like this:

1/ in your template create folder helpers
2/ Put in this folder file named hikashop.php and enter this content

<?php
defined('_JEXEC') or die;

class myHikaShop
{
	public static function placeBadges(&$image, &$badges, $vertical, $horizontal, $echo = true) {
		// your custom code
	}
}
3/ Go to HikaShop administration, menu Display - Views and search for show_block_img
4/ Click on show_block_img in column fFile in row with your template.
5/ Search for this code
if(!empty($this->element->badges)) 
	$html .= $this->classbadge->placeBadges($this->image, $this->element->badges, '0', '0',false);
and replace it with this code
if(!empty($this->element->badges)) {
	JHtml::addIncludePath( JPATH_BASE.'/templates/'.JFactory::getApplication()->getTemplate(false).'/helpers');
	$html .= JHtml::_('my.hikashop.placebadges', $this->image, $this->element->badges, '0', '0',false);
}
6/ save and close - you just made your template override, you can find your modified file in your template in html/com_hikashop/product folder.
7/ do the same for listing_img_title or any other file you need.

Pavel

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

  • Posts: 410
  • Thank you received: 15
6 years 7 months ago #278477

I prefer to use the above method I mentioned. After adding this code, there is no need to do anything else.

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

Time to create page: 0.089 seconds
Powered by Kunena Forum