product Options part image

  • Posts: 120
  • Thank you received: 2
10 years 11 months ago #158289

Hi dear
when create a product we have a Options part and when select a item in Options don't show Options product image.
I want show in my product page Options selected item image. how can do it?



this code for option part in my fronted:
$html='<span class="hikashop_option_name" ><a href="'.$optionInfo->product_url.'">'.$optionInfo->product_name.$options.'</a></span></td><tr><td><span style="padding-left:9px">'.JText::_( 'MAIN_OPTION_AF' ).'</span>'.$html;

i want show each options item image.

Last edit: 10 years 11 months ago by kaya.

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

  • Posts: 13201
  • Thank you received: 2322
10 years 11 months ago #158356

Hi,

You have to edit the view "product / show_default" and display the images thanks to a code like the one which can be found in the view "product / show_block_img".
The code to adapt is this one:

								$image_options = array('default' => true,'forcesize'=>$this->config->get('image_force_size',true),'scale'=>$this->config->get('image_scale_mode','inside'));
								$img = $this->image->getThumbnail(@$image->file_path, array('width' => $width, 'height' => $height), $image_options);
								if($img->success) {
									$attr = '';
									if (!empty ($this->element->images) && count($this->element->images) > 1) {
										$attr = 'onclick="return window.localPage.openImage(\'hikashop_main_image'.$variant_name.'\');"';
									}
}

The following user(s) said Thank You: kaya

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

  • Posts: 120
  • Thank you received: 2
10 years 11 months ago #158374

Thank you dear Xavier
what code add in my view "product / show_default" for display options images?

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

  • Posts: 12953
  • Thank you received: 1778
10 years 11 months ago #158377

Hello Kaya,
Note that another solution can be to simply add your option images through your main product description.

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

  • Posts: 120
  • Thank you received: 2
10 years 11 months ago #159317

Thank you dear Mohamed Thelji
but I want show images of selected product in options part.
this code show option part in product page

$this->setLayout('option');
echo $this->loadTemplate();
I want show images of option layout
please help me how can do it?
thank you

Last edit: 10 years 11 months ago by kaya.

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

  • Posts: 120
  • Thank you received: 2
10 years 11 months ago #159421

no one help me?

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

  • Posts: 83766
  • Thank you received: 13555
  • MODERATOR
10 years 11 months ago #159478

Hi,

Displaying the images of the options on the product page is not easy.
First, the options images need to be loaded from the database with a MySQL query on the hikashp_files table.
Then, the images need to be displayed with code similar (but a bit adapted) to the one of the show_img_block.
And if you want the option image displayed to change dynamically based on the selected option, you also need custom javascript code to do that.
Basically, it's not easy to do and requires proper development by a developer. If you're not one yourself, I would recommend to contact our partners for a quote on the project ( www.hikashop.com/home/our-partners.html ), or to find a developer via our commercial jobs forum, joomlancers.com or resources.joomla.org

The following user(s) said Thank You: kaya

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

  • Posts: 120
  • Thank you received: 2
10 years 11 months ago #159527

Thank you dear nicolas
i can echo option part images in product page by this code:

foreach($this->element->options as $optionElement){
                 $image_options = array('default' => true);
                $height = $this->config->get('product_image_y');
                $width = $this->config->get('product_image_x');
                $product_id = $optionElement->product_id;
                $producturl = JRoute::_("index.php?option=com_hikashop&ctrl=product&task=show&cid=$product_id");
               foreach($optionElement->images as $img){
                    $imgs = $this->image->getThumbnail(@$img->file_path, array('width' =>$width, 'height' => $height), $image_options);
                   echo '<img src="'.$imgs->url.'" />';
               }
it's php foreach loop now i want show each option product image with product name.
this code echo option product name outside my php foreach loop:
$html='<span class="hikashop_option_name" >'.$optionInfo->product_name.$options.'</span></td><td>'.$html
thank you

Last edit: 10 years 11 months ago by kaya.

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

Time to create page: 0.091 seconds
Powered by Kunena Forum