Characteristics Display per variant selection

  • Posts: 135
  • Thank you received: 5
1 year 9 months ago #342644

-- HikaShop version -- : 4.6.0
-- Joomla version -- : 4.1.5
-- PHP version -- : 7.3.27
-- Browser(s) name and version -- : Brave Version 1.39.122 Chromium: 102.0.5005.115 (Official Build) (64-bit)

Hi,

If I have 10 say standard colours in a characteristic called Powder Coat Colours.

Can I assign the colour palette to each variant? Meaning Red has a Red.img file assigned to it

Then when I add this characteristic to the product it will show the colour per selection?

I have 227 products, all have different number of variants based on product, colour availability for that product.
I really dont want to have to add each variant and then add each img file each time I create / update the product.

Is there a way to do this easily ?

Regards,
MSF

Attachments:

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

  • Posts: 81504
  • Thank you received: 13064
  • MODERATOR
1 year 9 months ago #342655

Hi,

One simple solution is to change the display mode of that characteristic to radio instead of dropdown and to add the HTML img tag of each image next to the name of the color in each value of the characteristic.
That will automatically apply to all the products.
You can read more about this here:
www.hikashop.com/support/documentation/2...isplay-by-color.html

What you're talking about is to inject an extra image to the product based on the selected color. That's possible with a custom plugin implementing the onHikashopBeforeDisplayView(&$view) event.
in $view->element->variants, you have an array of the images for each variant. So you can check the color of each variant and push an extra image for each variant.
If you're a developer, you should have no problem developing that.
Otherwise, if that's something you would like us to work on for you, we could develop the plugin for a small fee.

The following user(s) said Thank You: markfell

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

  • Posts: 135
  • Thank you received: 5
1 year 9 months ago #342681

Hi Nicolas,

Brilliant replay as usual, the only issue I think if I go to Radio button is, I am going to have maybe a possible 80 colours.
I was using 10 as an example, I am still awaiting the full colour palette.

So that would look crazy on the screen, let me work with it and see what I come up with.

I may come back from some more help :)

Regards,
MSF

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

  • Posts: 135
  • Thank you received: 5
1 year 9 months ago #342683

Hi Nicolas,

Ok, here is the scenario that I am now facing. I am told there are up to 300 custom colours that can be possible to be used.

I have a set of standard colours maybe up to 30. Then a range of custom colours up to 200, then the rest are not so used colours, but are requested every now and then.

How do I present that against a product?

Do I do what I did for the custom field, have a drop down with Yes - Standard Colours, Yes - Regular Custom, Yes - Non Regular Custom and then turn on whichever Characteristics dropdown is selected ?

Meaning I have 3 Characteristics :
Standard Colours [125]
Regular Custom [126]
Non Regular Custom [127]

Depending on the dropdown display that Characteristics

<script>window.Oby.registerAjax("hkAfterUpdateVariant", my_custom_function);
function my_custom_function()
{
if(document.getElementById('hikashop_product_characteristic_57').value == '56') {document.getElementById('hikashop_product_characteristic_125').style.display = 'block';document.getElementById('hikashop_product_characteristic_126').style.display = 'none';document.getElementById('hikashop_product_characteristic_127').style.display = 'none';
else
if(document.getElementById('hikashop_product_characteristic_57').value == '57') {document.getElementById('hikashop_product_characteristic_125').style.display = 'none';document.getElementById('hikashop_product_characteristic_126').style.display = 'block';document.getElementById('hikashop_product_characteristic_127').style.display = 'none';
else
if(document.getElementById('hikashop_product_characteristic_57').value == '58') {document.getElementById('hikashop_product_characteristic_125').style.display = 'none';document.getElementById('hikashop_product_characteristic_126').style.display = 'none';document.getElementById('hikashop_product_characteristic_127').style.display = 'block';
else
{document.getElementById('hikashop_product_characteristic_125').style.display = 'none';
document.getElementById('hikashop_product_characteristic_126').style.display = 'none';
document.getElementById('hikashop_product_characteristic_127').style.display = 'none';}
}
my_custom_function();</script>


Would this work, or am I pushing it?
Regards,
MSF

Last edit: 1 year 9 months ago by markfell. Reason: Put possible code into message

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

  • Posts: 81504
  • Thank you received: 13064
  • MODERATOR
1 year 9 months ago #342686

Hi,

Since you already have the "dynamic display" activated for the characteristics, the color dropdown will display only the colors available.
So you can have only one characteristic for all the colors. And one characteristic to select the "standard" / "regular" / "custom".
Then, when you create variants, you need to add variants of the standard colors only for the "standard" choice of the second characteristic, regular colors only for the "regular" choice of the second characteristic, etc.
That way, HikaShop will filter the colors in the color characteristic radio selector based on what is selected in the "standard" / "regular" / "custom". dropdown.
Note of course that the "standard" / "regular" / "custom" characteristic should be first in your product and the color characteristic second so that the customer select first "standard" / "regular" / "custom" and then only see the corresponding colors.

The following user(s) said Thank You: markfell

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

  • Posts: 135
  • Thank you received: 5
1 year 9 months ago #342711

Hi Nicolas,

That's why your so good, I would not have thought it that way around.
Thanks,
MSF

The following user(s) said Thank You: nicolas

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

Time to create page: 0.070 seconds
Powered by Kunena Forum