Display Custom Field after Characteristics chosen

  • Posts: 135
  • Thank you received: 5
1 year 10 months ago #341698

-- HikaShop version -- : 4.5.1
-- Joomla version -- : 4.1.3
-- PHP version -- : 7.3.27
-- Browser(s) name and version -- : Brave Version 1.35.103 Chromium: 98.0.4758.102 (Official Build) (64-bit)

Hi,

Is this a possible option?

If I have two options in my Characteristics (yes / no), if yes is chosen, can I then display a custom text field?

Ive looked and read the doco, set up my custom field and have it displayed as soon as the Product is chosen, but the Characteristics is set to no by default and the custom field is there.

Is there some display code that I need to change?

Regards,
MSF

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

  • Posts: 81361
  • Thank you received: 13035
  • MODERATOR
1 year 10 months ago #341702

Hi,

There is no option to do that.
This can be done with custom javascript code added to the page. Here is a thread on that same subject :
www.hikashop.com/support/forum/product-c...eristics.html#329128

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 10 months ago #341715

Hi,

Where do I inject this code ?

Regards,
MSF

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

  • Posts: 135
  • Thank you received: 5
1 year 10 months ago #341716

Hi,

I think it should go something like this ??

<script>
window.Oby.registerAjax("hkAfterUpdateVariant", my_custom_function);
function my_custom_function() {
if(document.getElementById('hikashop_product_characteristic_36').value == 'Yes') {
document.getElementById('hikashop_product_custom_item_value_17').style.display = 'block';
} else {
document.getElementById('hikashop_product_custom_item_value_17').style.display = 'none';
}
}
my_custom_function();
</script>


Based on the code from the page:

<div id="hikashop_product_characteristics" class="hikashop_product_characteristics">
<table class="hikashop_product_characteristics_table"><tr class="hikashop_characteristic_line_36" data-characrow="1"><td>Powder Coated:</td><td><select id="hikashop_product_characteristic_36" name="hikashop_product_characteristic[36]" class="custom-select" size="1" onchange="return hikashopVariantSelected(this);" data-characteristic="1" data-last="1">
<option value="" selected="selected">Please select</option>
<option value="34">No</option>
<option value="35">Yes</option>
</select>
</td></tr></table>

<!-- CUSTOM ITEM FIELDS -->
<div id="hikashop_product_custom_item_info" class="hikashop_product_custom_item_info">
<table class="hikashop_product_custom_item_info_table">
<tr id="hikashop_item_colouroptions" class="hikashop_item_colouroptions_line">
<td class="key">
<span id="hikashop_product_custom_item_name_17" class="hikashop_product_custom_item_name"><label for="colouroptions">Colour-options</label></span>
</td>
<td>
<span id="hikashop_product_custom_item_value_17" class="hikashop_product_custom_item_value"><input id="colouroptions" onchange="window.hikashop.toggleField(this.value,'colouroptions','item',0);" class="inputbox" type="text" name="data[item][colouroptions]" value="None" /></span>
</td>
</tr>
</table>
</div>


Regards,
MSF

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

  • Posts: 81361
  • Thank you received: 13035
  • MODERATOR
1 year 10 months ago #341717

Hi,

This depends on how your HikaShop product page is configured.
In your case, you're apparently using the default product page layout and thus you'll want to add such code in the file product / show_default via the menu Display>Views.
Note that as explained on that other thread, you can't just copy/paste the code. You also need to replace XXX, YYY and ZZZ by the corresponding values.
On your link, XXX should become hikashop_product_characteristic_36 and YYY should be 35 and ZZZ should be hikashop_item_colouroptions

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 10 months ago #341750

Hi Nicolas,

Once again, you show your coding talents with this software.

Thank you, works a treat.

Is there a way to have an API into Facebook shop?

Regards,
MSF

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

  • Posts: 81361
  • Thank you received: 13035
  • MODERATOR
1 year 10 months ago #341753

Hi,

Thanks !
You mean you want to send your products to a feacebook shop ? You can do that with the Google Products plugin preinstalled in HikaShop. It can generate a XML file of your products data which can be imported manually or periodically into Google Shopping and a Facebook shop:
www.facebook.com/business/help/125074381...2?id=725943027795860

The following user(s) said Thank You: markfell

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

Time to create page: 0.065 seconds
Powered by Kunena Forum