Template override for the characteristics

  • Posts: 8
  • Thank you received: 1
10 years 1 month ago #173960

-- HikaShop version -- : 3
-- Joomla version -- : 3.3.1
-- PHP version -- : 5.5.13
-- Browser(s) name and version -- : Chrome

Hi,

I'm looking for more documentation on the Template override for the characteristics. More than this page suggest : www.hikashop.com/support/documentation/6...tation.html#override

My goal is to move :

table class="hikashop_product_characteristics_table">

between :

<input id="hikashop_product_quantity_field_1" type="text" value="1" class="hikashop_product_quantity_field" name="quantity" onchange="hikashopCheckQuantityChange('hikashop_product_quantity_field_1',0,1);">

and the button add to cart.

Thanks.

(Look at the image attached for the final result wanted)

Attachments:
Last edit: 10 years 1 month ago by mm.carier.
The following user(s) said Thank You: jasmithartist

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

  • Posts: 82864
  • Thank you received: 13372
  • MODERATOR
10 years 1 month ago #173980

Hi,

We don't have more documentation on that subject.
But the characteristics display override is not the way to go anyway in your case.
You'll have instead to do two things:
1. edit the file "show_default" via the menu Display>Views and add some ob_start/ob_get_clean around the characteristic area in order to get the HTML of the characteristic display.
2. In that same file, remove the add to cart button display code and add your own HTML with the quantity box/add to cart button placed around the characteristic HTML. You'll want to be careful when you do that since the characteristic selection refreshes the quantity field/add to cart area for the current variant so you'll probably want to change the id of the area to deactivate the refresh on that part.

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

  • Posts: 8
  • Thank you received: 1
10 years 1 month ago #174086

Thanks for the reply.

When I put ob_start(); and ob_get_clean(); around the characteristic, it removed it.

<?php


		ob_start(); 

		if($this->params->get('characteristic_display')!='list'){
		$this->setLayout('show_block_characteristic');
		
		echo $this->loadTemplate();
		
		ob_get_clean();


	?>


Also, the quantity box/add to cart button, don't display well when I just copy and paste the HTML.


Here's the HTML that I copied and pasted :
<input id="hikashop_product_quantity_field_1" type="text" value="1" class="hikashop_product_quantity_field" name="quantity" onchange="hikashopCheckQuantityChange('hikashop_product_quantity_field_1',0,1);">
[/code]
<input type="submit" class="btn button hikashop_cart_input_button" name="add" value="Ajouter au panier" onclick="var field=document.getElementById('hikashop_product_quantity_field_1');if(hikashopCheckChangeForm('item','hikashop_product_form')){ return hikashopModifyQuantity('192059',field,1,0,'cart'); } else { return false; }">


So, if I do want you day, the final code should like (???) :



<?php
		ob_start(); 
        
	echo '<input id=\"hikashop_product_quantity_field_1\" type=\"text\" value=\"1\" class=\"hikashop_product_quantity_field\" name=\"quantity\" onchange=\"hikashopCheckQuantityChange(\'hikashop_product_quantity_field_1\',0,1);">';

		if($this->params->get('characteristic_display')!='list'){
		$this->setLayout('show_block_characteristic');
		
		echo $this->loadTemplate();
		
echo '<input type=\"submit\" class=\"btn button hikashop_cart_input_button\" name=\"add\" value=\"Ajouter au panier\" onclick=\"var field=document.getElementById(\'hikashop_product_quantity_field_1\');if(hikashopCheckChangeForm(\'item\',\'hikashop_product_form\')){ return hikashopModifyQuantity(\'192059\',field,1,0,\'cart\'); } else { return false; }">';

		ob_get_clean();

	?>


But it doesn't work... : (

Last edit: 10 years 1 month ago by mm.carier.

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

  • Posts: 82864
  • Thank you received: 13372
  • MODERATOR
10 years 1 month ago #174109

Hi,

These are general hints so that you can get going if you already know what you're doing.
You can't just copy/paste around the code, that won't work. It's much more complex to do.

For example, the goal of ob_get_clean is to flush the buffer and return the content of the buffer.
So of course, if you don't do anything with the return, it won't display the content of the buffer at all.
So instead of :
ob_get_clean();
you should have something like this:
$characteristics_html = ob_get_clean();
And then have a :
echo $characteristics_html;
where you want it to display, in between the quantity input and the add to cart.

And you can't just copy/paste the HTML of the quantity/add to cart button. The code needs to be dynamic (the product_id mainly which needs to be displayed from the product data).

If you don't feel you can do it on your own, I would recommend to contact our partners for a quote on that customization project:
www.hikashop.com/home/our-partners.html

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

Time to create page: 0.060 seconds
Powered by Kunena Forum