Display text depending on category
1. I have added some div classes inside show_default view file. Basically it is text in size tab...
Is there a way to hide it on some category products?
Example. Show it on products which are in category clothes but If product is in category shoes that div/text should be hidden.
2. Any ETA on hikashop 3 release?
Thank you
Please Log in or Create an account to join the conversation.
1. Yes you can add custom if condition like that in the view:
2. We can't give a date for now, still under development.
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
So code working great but I can't understand one thing.
I added code like this:
ID 158 is the category of the accessories and code works fine. It is showing on all products except on products from this category.
Now, I have category shoes with ID 159 and when I use it, products still are visible.
So not sure why with one category it is working and not with other?
Thanks
Please Log in or Create an account to join the conversation.
As Xavier said, you would need a second if for that other category, like that:
Please Log in or Create an account to join the conversation.
Still couldn't get it to work.
I spent 1 hour and tried all possible combinations.
I need to hide it on 2 categories. They ID's are 158 and 159
What I get is it will hide on one of them or will be shown on both.
Tried something like this:
What I am doing wrong?
Looking into code I only see difference in exclamation mark.
Thank you
Please Log in or Create an account to join the conversation.
Ah ok, I didn't understand that it's what you wanted.
In that case, you want to do that:
Please Log in or Create an account to join the conversation.
Thank you for help Nicolas.
Unfortunately it doesn't work. It seems it works only with category accessories with ID 158, tried shoes with ID 159 and it doesn't work.
I also tried with other categories ID's and no success.
Could be that problem is that some of products have more then one category added?
Attaching some screenshots.
Thanks
Please Log in or Create an account to join the conversation.
Can you try this code :
Please note that :
-!in_array('158',$categories) means, that the following command will be execute ONLY if the Id = 158 or 159 isn't found, so in this last code I provide your div will be display only for Id = 158 or 159
- '||' means OR, '&&' means AND, and so this condition won't be possible in your product page, unless a product have the 158 AND 159 categories Id.
Hope this will fit your needs.
Regards.
Please Log in or Create an account to join the conversation.
Thank you for replay Philip. Unfortunately it doesn't work like it should.
I have added your code provided and I have results like this:
Div is shown in category with ID 158 but not in any other. Reading your post it should be visible in category with ID 159 but it is not....
So it looks like that there is an issue with category ID 159 and others... Code don't want to work with it.
Thanks
Please Log in or Create an account to join the conversation.
Add the line:
var_dump($categories);
before the if and you'll see the list of categories for the product on each product page.
So you can check the id that you need to use in your if.
Please Log in or Create an account to join the conversation.
Ok, I added it and I see this:
Product in category accessories with id 158: array(1) { [0]=> string(3) "158" }
Product in category shoes with id 159: array(0) { } (same for all my other categories)
So I tried to remove view override, tried to use protostar template and results were same...
Is there anything I could do more?
Thanks
Please Log in or Create an account to join the conversation.
If your products have all a setted category that result is quite strange... I don't know what can leads to this, and so, can you provide back end user acces in order to process some tests by ourself ?
Of course, you must pass theses references thanks to our "Contact us" form, just don't forget to send it with an url link to this topic.
Awaiting news from you.
Regards.
Please Log in or Create an account to join the conversation.
Login details have been sent.
Thanks
Please Log in or Create an account to join the conversation.
The thing is that you have products with variants, so the categories check must be done on the main product and no on a variant.
The following code will solve all your problems
Please Log in or Create an account to join the conversation.
It didn't work but adding this did the trick:
Thank you very much to ALL for help.
Have a great day
Please Log in or Create an account to join the conversation.