Changing classes of characteristic radio buttons - Resolved

  • Posts: 180
  • Thank you received: 13
8 years 10 months ago #247806

-- HikaShop version -- : HikaShop Business 2.6.3 [1605112330]
-- Joomla version -- : 3.6.2
-- PHP version -- : 5.6

Hi

I wish to use Bootstrap classes on the characteristic radio buttons.

v4-alpha.getbootstrap.com/components/but...ox-and-radio-buttons

The only place I found to do this is on the admin files.

Can you please advise on the best way to go about this.

Thanks

Last edit: 8 years 6 months ago by esotechie.

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

  • Posts: 26253
  • Thank you received: 4040
  • MODERATOR
8 years 9 months ago #247814

Hi,

Yes, some parts are still in HikaShop core files.
But you can use the class override system in order to just override a specific function of an HikaShop file without having to modify the core file directly.

Here an example for the Image class file :
www.hikashop.com/forum/product-category-...atermark.html#184987

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

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

  • Posts: 180
  • Thank you received: 13
8 years 9 months ago #248491

Thank you for the reply Jerome.

What class and what file do I need to be working with to change the characteristic radio buttons?

Regards
Mehdi

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

  • Posts: 83989
  • Thank you received: 13604
  • MODERATOR
8 years 9 months ago #248494

Hi,

The simplest I think is to edit the file "show_block_characteristic" via the menu Display>Views and change the line:

echo $this->characteristic->displayFE($this->element, $this->params) . '</div>';
to:
echo str_replace('previous attributes to be replaced','new attributes replacing the old ones',$this->characteristic->displayFE($this->element, $this->params)) . '</div>';

The following user(s) said Thank You: esotechie

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

  • Posts: 180
  • Thank you received: 13
8 years 9 months ago #249916

Hi again

Thanks for that Nicolas.

That worked and didn't work.

The boxes appear OK, but the selections are not taken by Hikashop so the add to cart button adds the default values.

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

  • Posts: 83989
  • Thank you received: 13604
  • MODERATOR
8 years 9 months ago #249918

Hi,

Replace the onclick by the onchange attribute in your inputs and that should avoid the problem.

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

  • Posts: 180
  • Thank you received: 13
8 years 8 months ago #250113

Thanks or the reply Nicolsas.

Already tried that, but that breaks the Bootstrap management of the checkboxes and nothing seems to work.

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

  • Posts: 83989
  • Thank you received: 13604
  • MODERATOR
8 years 8 months ago #250128

Hi,

Then, instead of using bootstrap, just use your own CSS to mimic the appearance of bootstrap buttons.

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

  • Posts: 180
  • Thank you received: 13
8 years 8 months ago #250321

The idea was speed of development, simplicity and conformity.

:-(

Back to my previous question...

What class and what file do I need to be working with to change the characteristic radio buttons?

Last edit: 8 years 8 months ago by esotechie.

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

  • Posts: 26253
  • Thank you received: 4040
  • MODERATOR
8 years 8 months ago #250346

Hi,

It is not a class but a "type" and it's the "characteristic" one (administrator/components/com_hikashop/types/characteristic.php).
The function is "displayFE".

As previously, you can use the sample in the other thread to see how to perform an override of a core element.
www.hikashop.com/forum/product-category-...atermark.html#184987
Just change the folder from "helpers" to "types" to put your file override.

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

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

  • Posts: 180
  • Thank you received: 13
8 years 8 months ago #250773

Still none the wiser sorry.

I can not see in any of the files where the radio button table displayed in show_block_characteristic is built. All I seem to see are either selection methods or files relating to admin views.

What file is it that I have to amend the following pieces of code:

<div id="hikashop_product_characteristics" class="hikashop_product_characteristics">
	<div id="hikashop_product_characteristics" class="hikashop_product_characteristics">
	<table class="hikashop_product_characteristics_table"><tbody><tr><td>colour</td><td><div class="controls">
	<label for="hikashop_product_characteristic_63" id="hikashop_product_characteristic_63-lbl" class="radio">
	
	<input type="radio" name="hikashop_product_characteristic[6]" id="hikashop_product_characteristic_63" value="3" class="inputbox" size="1" onclick="return hikashopUpdateVariant(this);">Blue
	</label>
	<label for="hikashop_product_characteristic_65" id="hikashop_product_characteristic_65-lbl" class="radio">
	
	<input type="radio" name="hikashop_product_characteristic[6]" id="hikashop_product_characteristic_65" value="5" checked="checked" class="inputbox" size="1" onclick="return hikashopUpdateVariant(this);">Red
	</label>
	<label for="hikashop_product_characteristic_612" id="hikashop_product_characteristic_612-lbl" class="radio">
	
	<input type="radio" name="hikashop_product_characteristic[6]" id="hikashop_product_characteristic_612" value="12" class="inputbox" size="1" onclick="return hikashopUpdateVariant(this);">Turquoise
	</label>
</div>

Last edit: 8 years 8 months ago by esotechie.

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

  • Posts: 83989
  • Thank you received: 13604
  • MODERATOR
8 years 8 months ago #250790

Hi,

As Jerome said, it's the file administrator/components/com_hikashop/types/characteristic.php
I'm not sure what more we can say.
It's done by that code:

$main_html = '<table class="hikashop_product_characteristics_table">';
					$config =& hikashop_config();
					foreach($this->characteristics as $characteristic){
						$main_html.='<tr class="hikashop_characteristic_line_'.$characteristic->characteristic_id.'">';
						$values = array();
						$switch_done = false;
						if(!empty($characteristic->values)){
							foreach($characteristic->values as $k => $value){
								if(!$config->get('show_out_of_stock',1)){
									$hasQuantity = false;
									foreach($element->variants as $variant){
										foreach($variant->characteristics as $variantCharacteristic){
											if($variantCharacteristic->characteristic_id==$value->characteristic_id){
												//we have to add the default variant in the dropdown even if it doesn't have a quantity
												if($variant->product_quantity != 0){
													$hasQuantity = true;
												}elseif( $element->product_id==$variant->product_id && !$switch_done){
													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."\"]'); if(el) el.checked = true; hikashopUpdateVariant(el);";
													}
													
													$js = "
													window.hikashop.ready( function() {".$js."});";
													if (!HIKASHOP_PHP5) {
														$doc =& JFactory::getDocument();
													}else{
														$doc = JFactory::getDocument();
													}
													$doc->addScriptDeclaration("\n<!--\n".$js."\n//-->\n");
													$switch_done = true;
												}
											}
										}
									}
									if(!$hasQuantity) continue;
								}
								$values[$k]=$value->characteristic_value;
								/* name with price:
								$currencyHelper = hikashop_get('class.currency');
								$values[$k]=$value->characteristic_value.' ('.$currencyHelper->format($element->variants[$value->variant_product_id]->prices[0]->price_value,$element->variants[$value->variant_product_id]->prices[0]->price_currency_id).')';
								*/
							}
						}


						$html=$this->display(@$characteristic->characteristic_id,@$characteristic->default->characteristic_id,$values,$characteristic->characteristic_display_method);
						if($params->get('characteristic_display_text') && isset($characteristic->characteristic_value)){
							$html=$characteristic->characteristic_value.'</td><td>'.$html;
						}
						$main_html.='<td>'.$html.'</td></tr>';
					}
					$main_html.='</table>';
					$html = $main_html;
					break;
If you're looking for where the labels and inputs HTML is generated, it's in the Joomla HTML library called there thanks to the function $html = JHTML::_('select.'.$characteristic_display.'list', $this->values, $map, 'class="inputbox" size="1"' . $options, 'value', 'text', (int)$value,$id );

But again, there is nothing else in HikaShop.

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

  • Posts: 180
  • Thank you received: 13
8 years 6 months ago #255931

I finally sorted this with the assistance of a CSS expert, but adding a <span> into the mix. Works perfectly now.

Example page: halare-test.co.uk/shop/jersey-faux-wrap-top

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

Time to create page: 0.088 seconds
Powered by Kunena Forum