Product Picture Link

  • Posts: 53
  • Thank you received: 0
11 years 9 months ago #119898

Hi Guys

I would like to link the product image on the product page to add to cart html link so if a user clicks the product image they add the product to the cart. Currently if you click the image a lighbox pops up and the larger image is displayed. I would like to turn this off completly and instead link the image.

Can this be done and if so how can i do it?

Many Thanks

Nick

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

  • Posts: 2334
  • Thank you received: 403
11 years 9 months ago #119905

Hi Nick,

This can be done by editing your listing view and adding some html code.
It's not really difficult and many people on the forum did it.
However, if you're not confident with coding, please give us a link to your website and we'll help you with it ;)
You should also make sure that the "Link to the product page" option of your module/menu is enabled.

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

  • Posts: 53
  • Thank you received: 0
11 years 9 months ago #119912

Thanks Eliot

I dont mind giving it a go. I think i have found the file in:

DISPLAY>VIEWS>TEMPLATE>PRODUCT>LISTING

What im not so sure about is what part of the code to edit? Also do i input the "add to cart html link" code?

Thanks

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

  • Posts: 13201
  • Thank you received: 2322
11 years 9 months ago #119962

Hi,

Generally the file to edit is "product / show_default" via the menu Display > Views of HikaShop.
This is the product page view, it's not the "listing" one.

You have to edit the code for the image, you can remove it and add a common html tag to display the image.
The image link is in the variable "$this->element", around this tag add the add to cart button html tag.
And you will have the images which are adding the product to the cart when clicking on it.

The code to replace is:

//LAYOUT show_block_img
	$this->row = & $this->element;
	$this->setLayout('show_block_img');
	echo $this->loadTemplate();
And an example of the html link can be found in the toolbar of the product edition page.

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

  • Posts: 53
  • Thank you received: 0
11 years 9 months ago #120128

Hi Xavier

Thanks for the feedback. This is not working for me. Under "product/show_default" i can not find:

//LAYOUT show_block_img
	$this->row = & $this->element;
	$this->setLayout('show_block_img');
	echo $this->loadTemplate();

I only see this:
$this->row = & $this->element;
	$this->setLayout('show_block_img');
	echo $this->loadTemplate();

At this point i have no idea where exactly to put the html add to cart code. Can you help?

Another question if i put this code in the universal product display, as the add to cart html code is product specific, if i add to cart for different products wont just one product be added to cart. How do i change this so the right product is added to cart when i click the product image? I hope this makes sense haha

Many thanks

Nick

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

  • Posts: 2334
  • Thank you received: 403
11 years 9 months ago #120176

You're at the right place.
Point is you need some good php skills before starting this because you will have to add some js code in order to add your product to the cart. You can get some inspiration from the function displayButton in the file cart.php of administrator/com_hikashop/helpers
As Xavier said you'll have to use the informations stocked in $this->element to create a dynamic code.
If it sounds to difficult for you, you can still ask on the Commercial Jobs forum :).

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

Time to create page: 0.079 seconds
Powered by Kunena Forum