Luke
02-09-07, 09:01 PM
I just wrote this little php script that allows you to include a thumbnail image on the view cart page or anywhere else you want a thumbnail image. You need to upload this script to a server with php enabled as well as a mysql beck-end (merchant 5) in order for it to work.
Here is how you implement it, step-by-step
1. Copy this file, change the settings in the top of the file to match your server, and save it as get_image.php
<?php
/******* SETTINGS **************************************************/
// root url to images
define('BASEURL', 'http://store.yoursite.com/merchant2/');
// database host
define('DBHOST', 'localhost');
// database username
define('DBUSER', 'youruser');
// database password
define('DBPASS', 'yourpass');
// database name
define('DBNAME', 'yourdbname');
/******** DO NOT EDIT BEYOND THIS POINT!! **************************/
if (!isset($_GET['id']))
{
exit;
}
$prod_code = preg_replace('/[^a-zA-Z0-9]/', '', $_GET['id']);
$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
mysql_select_db(DBNAME, $conn);
$query = "
SELECT thumbnail
FROM s01_Products
WHERE code = '" . $prod_code . "'
LIMIT 1
";
$r = mysql_query($query);
while($row = mysql_fetch_assoc($r))
{
$thumb = $row['thumbnail'];
}
header('Content-Type: image/jpeg');
readfile(BASEURL . $thumb);
?>
2. Upload this script to a php-enabled server
(for my example, I uploaded it to www.my-non-miva-site.com/php/get_image.php)
3. Log into your miva merchant backend, find your view cart page, click edit, then click "basket contents", then wherever you want your image to show up, you can add this line:
<img src="http://www.my-non-miva-site.com/php/get_image.php?id=&mvt:item:code;" alt="&mvt:item:name;">
Remember to change www.my-non-miva-site.com to whatever the location is of the file you uploaded.
Hope this helps somebody! :D
This could be modified to display a thumbnail or regular image just about anywhere on your miva site. If you need help implementing this, send me a PM and I'll assist you.
Here is how you implement it, step-by-step
1. Copy this file, change the settings in the top of the file to match your server, and save it as get_image.php
<?php
/******* SETTINGS **************************************************/
// root url to images
define('BASEURL', 'http://store.yoursite.com/merchant2/');
// database host
define('DBHOST', 'localhost');
// database username
define('DBUSER', 'youruser');
// database password
define('DBPASS', 'yourpass');
// database name
define('DBNAME', 'yourdbname');
/******** DO NOT EDIT BEYOND THIS POINT!! **************************/
if (!isset($_GET['id']))
{
exit;
}
$prod_code = preg_replace('/[^a-zA-Z0-9]/', '', $_GET['id']);
$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
mysql_select_db(DBNAME, $conn);
$query = "
SELECT thumbnail
FROM s01_Products
WHERE code = '" . $prod_code . "'
LIMIT 1
";
$r = mysql_query($query);
while($row = mysql_fetch_assoc($r))
{
$thumb = $row['thumbnail'];
}
header('Content-Type: image/jpeg');
readfile(BASEURL . $thumb);
?>
2. Upload this script to a php-enabled server
(for my example, I uploaded it to www.my-non-miva-site.com/php/get_image.php)
3. Log into your miva merchant backend, find your view cart page, click edit, then click "basket contents", then wherever you want your image to show up, you can add this line:
<img src="http://www.my-non-miva-site.com/php/get_image.php?id=&mvt:item:code;" alt="&mvt:item:name;">
Remember to change www.my-non-miva-site.com to whatever the location is of the file you uploaded.
Hope this helps somebody! :D
This could be modified to display a thumbnail or regular image just about anywhere on your miva site. If you need help implementing this, send me a PM and I'll assist you.