- Posts: 70
- Thank you received: 4
php code to display price and image
12 years 4 months ago #157733
by intown
php code to display price and image was created by intown
-- 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:
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
-- 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:
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.
12 years 4 months ago #157736
by Xavier
Replied by Xavier on topic php code to display price and image
Hi,
For the price value:
For the image:
For the price value:
Code:
echo $this->element->prices[0]->price_value_with_tax;
// OR
echo $this->element->prices[0]->price_value;
For the image:
Code:
$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.
12 years 4 months ago #157896
by intown
Replied by intown on topic php code to display price and image
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
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.
12 years 4 months ago #157924
by intown
Replied by intown on topic php code to display price and image
Here is what I figured out, I also needed to add backslashes before every slash
Is there a better way to do this?
Thanks! -- Steven
Code:
$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.
12 years 4 months ago #157964
by nicolas
Replied by nicolas on topic php code to display price and image
you could do like that:
Code:
$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.173 seconds