Bagdes or labeling on products with filter

  • Posts: 136
  • Thank you received: 7
6 years 5 months ago #282305

-- HikaShop version -- : 3.2.1
-- Joomla version -- : 3.8.1
-- PHP version -- : 7.0.10

Hi

I though I could use badges as bagdes on top of the product image. But I can see in code and understand that I can only have 1 bagde on top of the product image?

If I made several bagdes and categories can I then loop through the bagdes to show more bagdes inline on top of the product image? Or would you suggest to use an other approach?

Tags as small images, or characteristics as small images or do I need to use some custom fields?

Best regards,
Henrik


.ninja { color: black; visibility: hidden; }
In case of fire:
1. git commit
2. git push
3. exit building
Attachments:
Last edit: 6 years 6 hours ago by flexsus.

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

  • Posts: 26000
  • Thank you received: 4004
  • MODERATOR
6 years 5 months ago #282309

Hello,

Product custom fields would be the easier for customization and specific placement.

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: 136
  • Thank you received: 7
6 years 1 day ago #291437

Hi Jerome

I know it's a bit old, this one.
I dropped the badge and went for Product Custom Fields.

I made a Custom Field with Column Name: 'product_labeling' Field Type: 'checkbox' and added 4 values. Then added this to override of 'listing_img_title.php' in the <!-- PRODUCT CUSTOM FIELDS --> section inside the 'foreach':

if($oneExtraField->field_namekey == 'product_labeling') {
	$product_labeling_title = explode(', ', $this->fieldsClass->show($oneExtraField, $this->row->$fieldName));
	$product_labeling_icon = explode(',', $this->row->$fieldName);
	$product_labeling = array_combine($product_labeling_title, $product_labeling_icon);
		echo '<div class="hikashop_product_labeling">';
		foreach ($product_labeling as $key => $item) {
			echo '<img src="'.HIKAMARKET_IMAGES.'icon-32/'.$item.'.png" alt="'.$key.'" title="'.$key.'" />';
		}
		echo '</div>';
		continue;
	
}

Result is like this, just as I want it to be:



My question is then on Filters.
I added a Filter, Type: Checkbox, Category: [Root>MainCaterory], Apply on: 'Custom fields', Custom fields: 'Product labeling', like this:


What's the 'LOGIC' used for?
What's the 'Values' used for?
Can't find it in any documentation on the subject and if I add something to 'Values' it is not saved. The same goes for 'Attributes' by the way, not saved.
I was hoping that I could add my value1 and value2 from 'Product labeling' to my filter, so that I would only have 2 checkbox working on this custom field, IF it was either value1 or value2.
And then add an other filter that works on value3, and then an other filter that works on value4.

Is this possible?

Best regards,
Henrik


.ninja { color: black; visibility: hidden; }
In case of fire:
1. git commit
2. git push
3. exit building
Attachments:
Last edit: 6 years 1 day ago by flexsus.

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

  • Posts: 4502
  • Thank you received: 610
  • MODERATOR
6 years 15 hours ago #291457

Hello,

Ok, let's speak about this by taking concrete example :
- Logic : Or & And will allow you to apply filter by restriction or association,
=> Example :
You have a product A with the custom field value : 1 & 2
and a product B with custom field value 2 & 3
Filter with OR and value 2 and 3 :
Results : product A & B will be display

Filter with AND and value 2 and 3 :
Results : only product B will be displayed

- Value : Imagine the selected custom field define as target for the filter is like to define product size, This new value will allow you to create size "group"
=> Example :
You enter : value 1, value 2, value 3 etc
Results : You will seen this :



If in your case that don't works it's probably because you enter text value, if you understand me well, expected value in filter settings can only be number.

Hope this will help you.
Regards

Last edit: 6 years 16 hours ago by Philip.
The following user(s) said Thank You: flexsus

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

  • Posts: 136
  • Thank you received: 7
6 years 8 hours ago #291494

Hi Philip

OK, I understand.
I think I can make a solution that will work in my case with some CSS-hack and some display:none. It will not be easy, but I think I know a way to do it.

Only problem is that I will make a filter that works on: value 1 OR value 2.
This will give my output in frontend:
Under 1 (I will do display:none)
1 to 2
2 and above (will do display:none)

But for the '1 to 2' I would like it to say something else, like 'organic'.
And I don't se any way to do that?

Regards,
Henrik


.ninja { color: black; visibility: hidden; }
In case of fire:
1. git commit
2. git push
3. exit building

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

  • Posts: 136
  • Thank you received: 7
6 years 6 hours ago #291496

By the way...
Attributes is not working/saving.
I try to add 'mycss' as a CSS class.

Regards,
Henrik


.ninja { color: black; visibility: hidden; }
In case of fire:
1. git commit
2. git push
3. exit building
Attachments:

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

  • Posts: 136
  • Thank you received: 7
6 years 6 hours ago #291498

Hi again

Sorry that this becoming a long topic, but it kind of connects.

I'm trying to get my head around the filters and noticed that the 'filter_namekey' is not updated in database, when you rename your filter. I did a filter I just called 'Test' and later renamed it to 'Økologisk'.



This is not a big problem, but since the CSS class uses this, it's getting hard to CSS-style it if you cannot relate to the meaning of the filter.



Is it a bug to be fix or do I just delete my filters and re-create them and on first time give them a name I would like to use for CSS and then rename them to something meaningfull?

Regards,
Henrik


.ninja { color: black; visibility: hidden; }
In case of fire:
1. git commit
2. git push
3. exit building
Attachments:
Last edit: 6 years 6 hours ago by flexsus.

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

  • Posts: 81481
  • Thank you received: 13062
  • MODERATOR
5 years 11 months ago #291516

Hi,

The namekey is not changed on purpose. That way, if you already had CSS in place for your filter, you don't have to modify it just because you wanted to rename your filter.
So yes, if you want to change the namekey you can either delete and recreate the filter or change its label in the database.

Regarding attributes, if you just add "mycss" that's not valid. In HTML, an attribute has this format: attributename="attributevalue"
So for example: class="mycssclass"
Or: style="font-size: 2em;"

Regarding the configuration of your filter, your questions are strange so I think that you didn't get how filters and custom product fields work together. If you have a custom field where you entered the values so that in the products you can select the values of the custom field, then you shouldn't enter any value in the filter. That way, it will automatically use the values of the custom field as choices of the filter. Then, with the OR logic selected, when you select two values in your filter, as long as a product has one of the two values selected it will be displayed. With the AND logic, both values would have to be selected for that product for it to be displayed.

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

  • Posts: 136
  • Thank you received: 7
5 years 11 months ago #291550

Hi Nicolas

The namekey is not changed on purpose. That way, if you already had CSS in place for your filter, you don't have to modify it just because you wanted to rename your filter.
So yes, if you want to change the namekey you can either delete and recreate the filter or change its label in the database.

Make sense! I deleted and recreated.

Regarding attributes, if you just add "mycss" that's not valid. In HTML, an attribute has this format: attributename="attributevalue"
So for example: class="mycssclass"
Or: style="font-size: 2em;"

Make sense! If I need a CSS-class I will add it as you describe.

Regarding the configuration of your filter,...

I tried to add a Custom Field type Checkbox with values:
Value | Title
myvaluename1 | Value Name 1
myvaluename2 | Value Name 2
myvaluename3 | Value Name 3

But as I understood Philip I cannot add a filter with values ' myvaluename1', 'myvaluename2', only '1' and '2', since it only takes numbers?
I can see in database, that it is TEXT, but it only saves if I put numbers.

So I changed my Custom Field type to:
Value | Title
1 | Value Name 1
2 | Value Name 2
3 | Value Name 3

It make the Filter work as I would like it to, but the output is:
Under 1
1 to 2
2 and above

And not the Titles from my Custom Field (which I have them in my language files).

I found this and maybe that's my problem?
www.hikashop.com/forum/filters-search/88...g-filter.html#258797


Regards,
Henrik


.ninja { color: black; visibility: hidden; }
In case of fire:
1. git commit
2. git push
3. exit building
Last edit: 5 years 11 months ago by flexsus.

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

  • Posts: 136
  • Thank you received: 7
5 years 11 months ago #291553

So for example: class="mycssclass"
Or: style="font-size: 2em;"


adding style as you say, gives Error.
adding class as you say, saves OK, but not shown.


.ninja { color: black; visibility: hidden; }
In case of fire:
1. git commit
2. git push
3. exit building

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

  • Posts: 81481
  • Thank you received: 13062
  • MODERATOR
5 years 11 months ago #291554

Hi,

As I said, you don't want to put any values in the filter.
That way, it will automatically use the values that you already have in the custom field, regardless of whether you use numbers or not in them.

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

  • Posts: 136
  • Thank you received: 7
5 years 11 months ago #291568

Hi
Yes, and that's what I did originally. My only problem with this approach is, that I have like 20 product labels.



From a Vendor point of view in Hikamarket, when he add a new product, he can decide and enable relevant product labels all in one place. He will have a check box for every 20 'values' of this Custom Field I made. Be it numbers or meaningfull names values. This will show relavant product labels as above picture. This part I can make working.

If I add a filter with meaningfull values and not numbers, the filter will show 20 checkboxes. This is not what I want it to do.

I'm trying to make a one(1) checkbox 'Organic' filter that works ONLY IF 1 OR 4 OR 20 OF some specific labels is enabled on the product, if we refers to the picture below.


This I can achieve if I use numbers for my values in my Custom Field and use number 1, 4, 20 in my Filter. But then the filter will show something like Philip showed. 'Under 1, 1-2, 3-4... above 20'.
And I don't want the front-end customer to select 1, 4, or 20 if he is searching for 'organic' products. I want a filter saying 'Organic' with a check box and if this is selected, it will filter products being 1, 4, or 20 enabled. Be it numbers in values (1,4,20) or as in picture: 'eu-ecolabel', 'eu-organic', 'dk-organic'.

In my perfect world :-) the Filter would look like this:
(Or even better, in values: 'eu-ecolabel', 'eu-organic', 'dk-organic' referring to the Custom Field values.)


The Filter would say: Organic (coming from 'Name') and it will have 1 checkbox and work if a product has any of 1,4, or 20 enabled.

But that I can't find out how to do?

Regards,
Henrik


.ninja { color: black; visibility: hidden; }
In case of fire:
1. git commit
2. git push
3. exit building
Attachments:
Last edit: 5 years 11 months ago by flexsus.

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

  • Posts: 81481
  • Thank you received: 13062
  • MODERATOR
5 years 11 months ago #291576

Hi,

Then:
You can use numbers in the custom field values and in the filter.
In the custom field, you want the values, with their numbers, to be grouped together.
For example, all the organic labels are between 4 and 16
Then, you enter 4 and 16 as the two values in the filter
You configure the filter as a checkbox
You'll then have 3 checkboxes with your filter: under 4, between 4 and 16, above 16.
Then, you hide the first and third with CSS (display:none;)
And you change the text between 4 and 16 with a translation override of the translation key FROM_X_TO_Y so that it says "organic" instead.
That way, when you check your organic checkbox, it will filter the products to keep only the ones with a value selected between 4 and 16.
However, the only drawback here is that it supposes that the value in the custom field is a number. So if you select several numbers, it won't be a number anymore it will bet a string (text) and thus the filtering won't work properly.

I would recommend to actually do it differently:
Don't use the filter system. Instead, create a module (or a view override of the listing) to add your checkbox in a form which would submit to the products listing. Then, develop a small plugin of the group "hikashop" and implement in it the onBeforeProductListingLoad trigger (
www.hikashop.com/support/documentation/6...reProductListingLoad ) in order to get the value of the checkbox and add the proper condition to the MySQL query loading the products.
It's a lot cleaner and will allow you to do exactly what you need, but it requires a bit of development.

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

Time to create page: 0.126 seconds
Powered by Kunena Forum