Change characteristic popup if only one option

  • Posts: 180
  • Thank you received: 13
12 years 4 months ago #57616

There is a need to occasionally have a product with only one characteristic as a variant, e.g. we have a shirt only in Red. But we want it to be a product with a variant because in future we may add other colours.

Now with only one option in a characteristic, it looks on with a pop-up with only one choice. What I would like to do is to either not have the Characteristic appear as a pop-up on the product page, or for it to appear as a Text instead of a popup.

I see that the code is placed by view->product->show_block_charasteristic, but I can not see where it is put together. Can you please direct me to the correct file?

Thanks

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

  • Posts: 12953
  • Thank you received: 1778
12 years 4 months ago #57618

Hello,

I think that you'll probably have to edit the show_default file of the product view.

Hope this will help you.

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

  • Posts: 180
  • Thank you received: 13
12 years 4 months ago #57635

Thanks for the reply Mohamed,

The view->product-> show_default does not render the characteristic popup. That is definitely done by view->product->show_block_charasteristic.

But I do not know what the following calls:

$this->characteristic->displayFE($this->element, $this->params)

I need to know where the value which is fetched is put together. I may be wrong, but I do not think they are in any of the view files.

Last edit: 12 years 4 months ago by esotechie.

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

  • Posts: 82820
  • Thank you received: 13366
  • MODERATOR
12 years 4 months ago #57713

You could simply add that code at the beginning of that show_block_characteristic file:
<?php if(empty($this->element->variants) || count($this->element->variants)<2) return true; ?>

That will skip the display of the characteristics if there is only one variant.
The characteristic itself is done via that file in the file administrator/components/com_hikashop/types/characteristic.php which you can override as explained in the documentation:
www.hikashop.com/en/support/documentatio...tation.html#override
But for such a small modification, you should rather do what I said.

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

  • Posts: 180
  • Thank you received: 13
12 years 4 months ago #57776

Thanks Nicolas,

Do we already have a function I can use to check the number variants or the number of elements in the popup?

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

  • Posts: 82820
  • Thank you received: 13366
  • MODERATOR
12 years 4 months ago #57777

What do you mean by "in the popup" ?

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

  • Posts: 180
  • Thank you received: 13
12 years 4 months ago #57784

Drop down menu :)

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

  • Posts: 82820
  • Thank you received: 13366
  • MODERATOR
12 years 4 months ago #57846

Mmm. I'm not sure I understand.
The code I gave in my message does just that:
<?php if(empty($this->element->variants) || count($this->element->variants)<2) return true; ?>

See the count($this->element->variants)<2

It checks that count of variants is below 2 and if so, it returns (with the return true; code) so that it won't display the rest of the file.

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

  • Posts: 180
  • Thank you received: 13
12 years 4 months ago #57849

I'm sorry Nicoals. I did not read your post properly, I though because you said add "that" code at the beginning, you wrote the line of code which I should be adding my code before. But you actually had written the code for me to use.

Thank you very much. Working EXACTLY as I wanted it to. Sorry about the time wasting after that.

P.S. I'm not sure if you are aware, but for some reason the view file is called block_charasteristic. It can cause a little confusion when searching for a view with the term "characteristic".

Last edit: 12 years 4 months ago by esotechie.

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

  • Posts: 82820
  • Thank you received: 13366
  • MODERATOR
12 years 4 months ago #57892

Thank you for the feedback. We'll change the name of the file (you will have to do again your customization after updating).

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

Time to create page: 0.076 seconds
Powered by Kunena Forum