php code to display price and image

  • Posts: 70
  • Thank you received: 4
11 years 3 months ago #157733

-- HikaShop version -- : 2.3.1
-- Joomla version -- : 3.3.0

Hi I am working on integrating a custom script with hikashop.

I have been editing show_tabular product view

To call the product name I am using this code:

<?php echo $this->element->main->product_name; ?>

How do I display
The price without any formatting , just need the numbers
The main product image starting with http://

I looked around and could not find what these code snippets should be.

Thanks! -- Steven

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

  • Posts: 13201
  • Thank you received: 2322
11 years 3 months ago #157736

Hi,

For the price value:

echo $this->element->prices[0]->price_value_with_tax;
// OR
echo $this->element->prices[0]->price_value;

For the image:
$config = hikashop_config();
$image = reset($this->element->images);
$path = JPATH_ROOT.DS.$config->get('uploadfolder').$image->file_path;
echo $path;

The following user(s) said Thank You: intown

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

  • Posts: 70
  • Thank you received: 4
11 years 3 months ago #157896

Thanks so much for the reply and info.

The code to call the price worked great


For the code to call the image.
the entire path is being called. /home/xxxx/media/..../filename.jpg
I want the output to look like
domain.com/media/....../filename.jpg

What would I change the code to get the desired output?

Thanks! -- Steven

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

  • Posts: 70
  • Thank you received: 4
11 years 3 months ago #157924

Here is what I figured out, I also needed to add backslashes before every slash

$config = hikashop_config();
$image = reset($this->element->images);
$path = JPATH_ROOT.DS.$config->get('uploadfolder').$image->file_path;
$shortpath = substr($path, 47);
$shortpathslashes = str_replace("/", "\\/", $shortpath);

echo "path: " . $path . "<br />";
echo "shortpath: " . $shortpath . "<br />";
echo "shortpathslashes: http:\/\/www.lockharttactical.com" . $shortpathslashes;

Is there a better way to do this?

Thanks! -- Steven

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

  • Posts: 84298
  • Thank you received: 13694
  • MODERATOR
11 years 3 months ago #157964

you could do like that:

$config = hikashop_config();
$image = reset($this->element->images);
echo HIKASHOP_LIVE.$config->get('uploadfolder').$image->file_path;

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

Time to create page: 0.069 seconds
Powered by Kunena Forum