Linked parent-child product characteristics ddns

  • Posts: 19
  • Thank you received: 0
10 years 8 months ago #149129

-- url of the page with the problem -- localhost
-- HikaShop version -- :HK Essential: 2.3.0
-- Joomla version -- :2.5.19
-- PHP version -- : 5.3.13
-- Browser(s) name and version -- : FreFox 27.0.1
-- Error-message(debug-mod must be tuned on) -- : Error_message

Hi, I would like to implement linked dynamic comboboxes for product charateristics (ie parent-child drop-downs) using an approach similar to the reference listed below:
Dynamic Dropdowns with charateristics & options

Being a novice HK user, I would like to ask a few questions before venturing in coding:

1. Child drop-down location. My understanding is that the child drop-down html code needs to be explicitely defined. If so, in which file should the child drop-down be inserted into (show_block_characteristics.php, option.php, ..) and how should the select html skeleton be structured? (Note that parents and children share the same class.)

<!-- Parent drop-down skeleton: --> 
<select id="hikashop_product_characteristic_1"  onchange="return hikashopUpdateVariant(this);">.. 
	<option value="10" class="opt1" selected="selected">Option 1</option>
	<option value="11" class="opt2">Option 2</option>
	<option value="12" class="opt3">Option 3</option>
	...
</select>
....
<!-- Child drop-down skeleton: -->
<select id="hikashop_product_option_1" name="hikashop_product_option[1]" onchange="hikashopChangeOption();;">
	<option value="0" class="opt1" selected="selected">None</option>
	<option value="100" class="opt1"> Option 1.1</option>
	...
	<option value="0" class="opt2" selected="selected">None</option>
	<option value="200" class="opt2"> Option 2.1</option>
	....
	<option value="0" class="opt3" selected="selected">None</option>
	<option value="300" class="opt3"> Option 3.1</option>
	...
</select>

2. jQuery. The child option drop-down should only reveal items that share the same class as their parent (ie opt1, opt2, etc.), the other items remaining hidden. Can the js module be written with jQuery? If so, where should the jQuery module be located at?
// jQuery module:
function hikashopUpdateVariant(elSel) { .... };

3. Upgrades. Currently, I am using Essentials v 2.3.0. How code resilient would those changes be in regard to future releases?

TIA for any clarifications and hints.

Last edit: 10 years 8 months ago by Helveticus.

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

  • Posts: 82864
  • Thank you received: 13372
  • MODERATOR
10 years 8 months ago #149203

Hi,

1. All the code relative to the characteristics display is actually in the file administrator/components/com_hikashop/types/characteristic.php so that's probably where you want to do your modifications.

2. There is a high probability that jQuery is already loaded on your frontend. If that's not the case, you can easily load it with that line of PHP code:

3. If you modify directly the types/characteristic.php file, you'll loose your changes when you update HikaShop. An alternative is to do a characteristic display template override as explained in our developer documentation : www.hikashop.com/support/support/documen...r-documentation.html
That way, you won't loose your code when you update HikaShop.

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

  • Posts: 19
  • Thank you received: 0
10 years 8 months ago #149215

Thank you for your explanations.

Meanwhile, I posted a new message about the same topic considering html5 data attributes as a filter option. This would offer better flexibility in case of multiple characteristics drop-downs:
www.hikashop.com/forum/product-category-...in-prod-charact.html

Last edit: 10 years 8 months ago by Helveticus.

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

Time to create page: 0.062 seconds
Powered by Kunena Forum