Characteristics display

  • Posts: 1119
  • Thank you received: 114
8 years 1 month ago #249126

Hi,

I am looking to customize my product page as per this docs and same would apply for size selection. :

www.hikashop.com/support/documentation/2...isplay-by-color.html

So question. Would it be possible to apply this only for product page and keep words in module filtering?

We have 2 characteristics. One is for size and other for color. As we create product for every color there is no need to display color characteristic on product page. Is there a way to hide it? I have looked into css but it looks like there is no class applied...

Thanks

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

  • Posts: 1119
  • Thank you received: 114
8 years 1 month ago #249137

I have found what i need and it works but there is one issue.

If i use dropdown selection of characterictics in product page and default variant is sold system will remove that selection and shows next possible variant. That's ok
However if i use radio button system will show that item is sold out and non of the possible variants is selected.

Tried with protostar template and it was same...

How can this be fixed?

Thanks

Last edit: 8 years 1 month ago by kyratn.

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

  • Posts: 82723
  • Thank you received: 13338
  • MODERATOR
8 years 1 month ago #249143

Hi,

I'm sorry but I don't understand your problem. Could you provide a screenshot of the problem ?
Could you also provide a link to the product page and a screenshot of its settings and its variants listing ?

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

  • Posts: 1119
  • Thank you received: 114
8 years 1 month ago #249180

Hi,

Sorry, maybe I was not clear enough.

So the issue is that if product has variants like sizes S, M, L, XL and default variant is set to S as example, and If this variant is sold out and you come to product page you will see that product is soldout. This is happening if Characteristics selection method is set to radio buttons. All works fine with dropdown selection. I think system should select next possible variant automatically but it does not....

You can check this link: kyra.lt/demoadmin/tampres/leginsai-pinky-pilka
Default product variant is S which has quantity of 0 and you get Sold out message until you choose one of the possible variants.

This is misleading for buyer experiences and to work for it as it should I would have to set another variant as default if default variants would be sold out manually for every product...

I have attached screenshots to be more clear and I hope you understand what is the issue.

Thanks

Attachments:
Last edit: 8 years 1 month ago by kyratn.

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

  • Posts: 82723
  • Thank you received: 13338
  • MODERATOR
8 years 1 month ago #249186

Hi,

Ok. I see what you mean now.
Then please try replacing the code:

$id = 'hikashop_product_characteristic_'.$characteristic->characteristic_id;
													$js = "
													window.hikashop.ready( function() {hikashopUpdateVariant(document.getElementById('".$id."'));});";
by:
if($characteristic->characteristic_display_method == 'dropdown'){
														$id = 'hikashop_product_characteristic_'.$characteristic->characteristic_id;
														$getElement = "document.getElementById('".$id."')";
													}else{
														$id = 'hikashop_product_characteristic['.$characteristic->characteristic_id.']';
														$getElement = "document.querySelector('[name=\"".$id."\"]')";
													}
													
													$js = "
													window.hikashop.ready( function() {hikashopUpdateVariant(".$getElement.");});";
As that's apparently a bug, that's a fix we would include in HikaShop by default if that works so let us know how it goes.

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

  • Posts: 1119
  • Thank you received: 114
8 years 1 month ago #249220

Hi,

I would be happy to try it but which of the files I should modify?
I have done quick search and couldn't find. I assume its not in one of the view files..

Thanks

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

  • Posts: 82723
  • Thank you received: 13338
  • MODERATOR
8 years 1 month ago #249246

Hi,

Sorry for that. It's in the file administrator/components/com_hikashop/types/characteristic.php

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

  • Posts: 1119
  • Thank you received: 114
8 years 1 month ago #249272

Hi,

So i have tried to replace code and nothing has changed :(

Still wont select next variant using radio buttons

Any other solution?

Thanks

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

  • Posts: 82723
  • Thank you received: 13338
  • MODERATOR
8 years 1 month ago #249275

Hi,

Then, instead of that code, please try that code:

if($characteristic->characteristic_display_method == 'dropdown'){
														$id = 'hikashop_product_characteristic_'.$characteristic->characteristic_id;
														$getElement = "document.getElementById('".$id."')";
													}else{
														$id = 'hikashop_product_characteristic['.$characteristic->characteristic_id.']';
														$getElement = "document.querySelector('[name=\"".$id."\"]')";
													}
													
													$js = "
													window.hikashop.ready( function() {hikashopUpdateVariant(".$getElement.");});";

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

  • Posts: 1119
  • Thank you received: 114
8 years 1 month ago #249306

Hi,

Unfortunately it didn't work!

I may be wrong but this your code looks for me same as in your previous post??

Thanks

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

  • Posts: 82723
  • Thank you received: 13338
  • MODERATOR
8 years 1 month ago #249325

Hi,

You're right, I've pasted the wrong code...
Here is the new code to try:

if($characteristic->characteristic_display_method == 'dropdown'){
														$id = 'hikashop_product_characteristic_'.$characteristic->characteristic_id;
														$js = "hikashopUpdateVariant(document.getElementById('".$id."'));";
													}else{
														$id = 'hikashop_product_characteristic['.$characteristic->characteristic_id.']';
														$js = "var el = document.querySelector('[name=\"".$id."\"]'); el.checked = true; hikashopUpdateVariant(el);";
													}
													
													$js = "
													window.hikashop.ready( function() {".$js."});";

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

  • Posts: 1119
  • Thank you received: 114
8 years 1 month ago #249336

Hi,

I can confirm that you code is working, thank you for looking into this.

However I have another few questions.

1. To modify the look of the radio buttons I have added span classes to characteristics like that:

<span class="test">S</span>

and added such css to my template:
.hikashop_product_characteristics_table td label > input:checked + span  {
  border: 1px solid #3598db;
  color: #fff;
  background-color: #3598db;
}
.hikashop_product_characteristics_table td label span  {
     margin-right: 0px;
     border: 1px solid #666666;
     width: 64px;
     height: 40px;
     display: inline-block;
     text-align: center;
     vertical-align: middle;
     border-radius: 2px;
     color: #666666;
     padding-top: 9px;
     text-decoration: none;
     font-size: 18px;
     cursor:pointer;
 }

Is there a way to hide html classes from dropdown? In admin panel product->variant-> main options->in dropdown selection it shows:
<span class="test">S</span>

but I would like to have just "S". Just for more user friendly when changing it. Same applies for front-end dropdown selection if need it.....

Screenshot attached to be more clear.

2. We use 2 characteristics. SIZE and COLOR. As for every color we create new product we would like to hide Color characteristic display from product page and display only Size. How can I hide it or How can I apply different css for different characteristics?

Thank you

Attachments:

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

  • Posts: 82723
  • Thank you received: 13338
  • MODERATOR
8 years 1 month ago #249384

Hi,

1. Edit the file administrator/components/com_hikashop/types/characteristic.php and change the line:

$this->values[] = JHTML::_('select.option', $key,$val);
to:
$this->values[] = JHTML::_('select.option', $key,($characteristic_display!='radio'?strip_tags($val):$val));

2. In the same file, change the line:
$main_html.='<tr>';
to:
$main_html.='<tr class="hikashop_characteristic_line_'.$characteristic->characteristic_id.'">';
that way, each characteristic line will have its own class for your CSS code.

The following user(s) said Thank You: kyratn

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

  • Posts: 1119
  • Thank you received: 114
8 years 1 month ago #249395

Thank you very much. All works fine now! As usual brilliant support. Keep it up!

Just last question. Will this be added by default to hikashop or i should save these changes?

Thank you

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

  • Posts: 82723
  • Thank you received: 13338
  • MODERATOR
8 years 1 month ago #249397

Hi,

Yes, it will be.

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

  • Posts: 1119
  • Thank you received: 114
8 years 1 month ago #249429

Hi,

Thats's great but I just added few products and found few more small issues. Everything works fine but if this could be updated then it would be good.

1. In product->add variants->and select characteristic. For faster search i enter first letter of my characteristic and it find it asap, just need to press save.
However if search for "S" it will find span class...same applies to other letters from "span class". I have attached screenshot with name "variants1" So you should understand what mean.

2. If default product variant is unpublished span class isnt applied. I guess its because of input checked use. If published all is fine.
Should i look into my css or it is more related to your code? I have attached 2 more screenshots to be more clear.

The code to give color for checked variant i use is this:

.hikashop_product_characteristics_table td label > input:checked + span

Thank you

Attachments:
Last edit: 8 years 1 month ago by kyratn.

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

  • Posts: 82723
  • Thank you received: 13338
  • MODERATOR
8 years 1 month ago #249437

Hi,

1. The search is done in MySQL and there is no function in MySQL to be able to remove HTML tags in strings (that has to be done in PHP). So that's unfortunately not possible as doing the search in PHP is not possible either for performance issues.

2. You're not supposed to select a default variant that you don't enable.
It's like trying to add to cart a product that is unpublished. That shouldn't happen.
So I don't see why you're trying to do that ?

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

  • Posts: 1119
  • Thank you received: 114
8 years 1 month ago #249461

Hi,

1. I see. thanks for clarification.

2. I understand what you mean. I don't try to select default variant...The problem is that if default variant is unpublished, the next possible variant has no checked="checked" inside input and my span class with color isn't applied because of this.
That's not a big deal. I keep product published until all variants are sold. I just found this small issue and tho I will share or something :)

Thanks

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

  • Posts: 1119
  • Thank you received: 114
8 years 1 month ago #249638

Hi,

So I just found another issue and have no idea how to fix it.

If product is sold out and characteristics display method is set to radio buttons I get js error and all js on that product page isn't working.

Uncaught TypeError: Cannot set property 'checked' of null(anonymous function)
@ golfas-dragon-melyna:572i
@ jquery.min.js:2fireWith
@ jquery.min.js:2ready
@ jquery.min.js:2K
@ jquery.min.js:2

I tried with default file with no modifications and it was same. How could I fix it?

Thanks

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

  • Posts: 82723
  • Thank you received: 13338
  • MODERATOR
8 years 1 month ago #249662

Hi,

Can you provide a link to a product page with that issue please ?

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

Time to create page: 0.091 seconds
Powered by Kunena Forum