Thumbnail (scaled down) Product Images (gif or jpg) in Checkout Phase - tested with V4.1 and V5.1
Assuming you have some product images whose filenames are related to your product references then it is possible to display these images at the checkout phase. The images can be in either jpg or gif format but the extensions must lower case for the code to work. These patches can be implemented with just a single line of perl but have grown rather large due to the addition of the option of scaling down the image sizes.
To do this make the following changes to ShoppingCart.pl and ActinicOrder.pm (also change ActinicSCCode.fil if using V5) in your Site1 folder (make backup copies first).
Make sure you use a text editor and not a word processor program (see www.editpadlite.com if you need one).
The following code has been tested on Win32 and Unix with Catalog V4.1 and V5.1. The code should work with Business and other version numbers.
In the patches that follow the 1st 6 lines are user modifiable:
1) You should replace '../htdocs/acatalog/'
with the information from Actinic / Advanced / Network field:- "Path From CGI-BIN To Catalog Directory".
2) Change $NorcatScale to whatever scale down factor you like ( 2 gives half sized images, 1 full size, fractions are OK ). You can set a different scale for the Add to Cart page (ShoppingCart.pl patch) and The order summary (AcinicOrder.pm and (ActinicSCCode.fil - V5)). This can be useful as there is less space on the summary pages, especially if multi currency is in use.
3) Also if you have a prefix or postfix (4) to your image file names (i.e. bits that aren't part of the product reference) then add that text to $NorcatImagePrefix and $NorcatImageSuffix.
5) You can also amend the code that starts and ends (6) the cart image. Note that this code is slightly different between the Add to Cart (ShoppingCart.pl) page and the other order pages as there is more room on the Add to Cart page.
Patching instructions:-
In ShoppingCart.pl (V4 and V5 versions)
locate the line (there should be only one instance)
$VariableTable{$::VARPREFIX."PRODUCTNAME"} = $sLine; # add the product name to the var table
change this line to read
$VariableTable{$::VARPREFIX."PRODUCTNAME"} = $NorcatImage . $sLine; # add the product name to the var table
and INSERT the following code immediately above it:-
############################# CHECKOUT-IMAGE with scaling V1.1 #######################################
# ShoppingCart.pl (V4 and V5 versions) patch
#
# author Norman Rouxel www.drillpine.biz (V11)
# user modifiable variables
my $NorcatCatPath = '../htdocs/acatalog/'; # Path From CGI-BIN To Catalog Directory (Actinic/Advanced/Network)
my $NorcatImagePrefix = ''; # optional text that prefixes product ref in image filenames
my $NorcatImageSuffix = ''; # optional text that follows product ref in image filenames
my $NorcatScale = 2; # e.g. 2 -> half size thumbnails. 1 -> full size. Fractions OK.
my $NorcatImageStart = '' . $Response[1] . '';
change it to read
$ProdName .= '
' . '' . $Response[1] . $NorcatImage . ' | ';
and INSERT the following code immediately above it:-
############################# CHECKOUT-IMAGE with scaling V1.1 #######################################
# ActinicOrder.pm (V4 versions only) patch
#
# author Norman Rouxel www.drillpine.biz (V11)
# user modifiable variables
my $NorcatCatPath = '../htdocs/acatalog/'; # Path From CGI-BIN To Catalog Directory (Actinic/Advanced/Network)
my $NorcatImagePrefix = ''; # optional text that prefixes product ref in image filenames
my $NorcatImageSuffix = ''; # optional text that follows product ref in image filenames
my $NorcatScale = 2; # e.g. 2 -> half size thumbnails. 1 -> full size. Fractions OK.
my $NorcatImageStart = '
'; # end HTML for image
# end of user modifiable variables
my $NorcatRef = $$pProduct{'REFERENCE'}; # Our product reference
# end of ActinicOrder.pm & ActinicSCCode.fil (V5 versions only) patch - main patch follows
Now copy the main patch (from the end of this document) immediately below the bit you just inserted.
Remember that if you're running Actinic V5 to apply this patch to both ActinicOrder.pm AND ActinicSCCode.fil.
Here is the main patch code that goes into all the scripts.
################ MAIN PATCH - CHECKOUT-IMAGE with scaling V1.1 #######################################
# end of module specific code - what follows is identical in all scripts
my $NorcatImage = '';
my $NImageWidth = 0;
my $NImageHeight = 0;
#
# GIF images - in case anyones still using them. Just use Canvas Size in bytes 7-10.
# We never touch the LZW compressed part so Unisys can't extort "their" royalty.
#
if ( -e $NorcatCatPath . $NorcatImagePrefix . $NorcatRef . $NorcatImageSuffix . '.gif' ) # look for a .gif
{
open(ImageFile, $NorcatCatPath . $NorcatImagePrefix . $NorcatRef . $NorcatImageSuffix . '.gif');
binmode(ImageFile); # needed for Win32 platforms
my $NorcatGif;
if ( ( read(ImageFile, $NorcatGif, 10) == 10 ) && ( substr($NorcatGif,0,3) eq 'GIF' ) ) # make sure it's a GIF
{
$NImageWidth = ord(substr($NorcatGif,7,1)) * 256 + ord(substr($NorcatGif,6,1)); # gif width at bytes 8,7
$NImageHeight = ord(substr($NorcatGif,9,1)) * 256 + ord(substr($NorcatGif,8,1)); # gif height at bytes 10,9
$NImageHeight = int($NImageHeight / $NorcatScale); # scale down
$NImageWidth = int($NImageWidth / $NorcatScale); # scale down
$NorcatImage = $NorcatImageStart . $NorcatImagePrefix . $NorcatRef . $NorcatImageSuffix .
'.gif" width=' . $NImageWidth . ' height=' . $NImageHeight . $NorcatImageEnd;
}
close ImageFile;
}
#
# JPEG images - size information isn't in a fixed place. Skip through headers till a Start Of Frame and collect size.
# If any problems like unknown data in file just fail silently and the image won't be shown.
#
elsif ( -e $NorcatCatPath . $NorcatImagePrefix . $NorcatRef . $NorcatImageSuffix . '.jpg' ) # look for a jpeg
{
my $N1stByte = 0;
my $N2ndByte = 0;
my $NError = 0;
my $NFoundIt = 0;
open(ImageFile, $NorcatCatPath . $NorcatImagePrefix . $NorcatRef . $NorcatImageSuffix . '.jpg');
binmode(ImageFile); # needed for Win32 platforms
if ( not eof(ImageFile) ) {read(ImageFile, $N1stByte, 1)} # 1st byte
if ( not eof(ImageFile) ) {read(ImageFile, $N2ndByte, 1)} # 2nd byte
if ( (ord($N1stByte) == 0xFF) && (ord($N2ndByte) == 0xD8) ) # good JPG header
{
while ( (! $NError) && (! $NFoundIt) )
{ # scan markers till SOFn
my $NNextByte;
$NError = 1;
if ( not eof(ImageFile) )
{
read(ImageFile, $NNextByte, 1);
my $NByte = ord($NNextByte); # convert to unsigned integer
if ( $NByte == 0xFF ) # Must be an FF
{
while ( (not eof(ImageFile) ) && ( $NByte == 0xFF ) ) # allow for pad FF bytes
{
read(ImageFile, $NNextByte, 1);
$NByte = ord($NNextByte);
}
if ( $NByte != 0xDA ) # abandon if Start Of Scan marker
{
# Start of Frame(n) contains images sizes - Marker codes 0xC0 to 0xCF (excluding 0xC4 and 0xCC)
if ( ($NByte < 0xC0) ||($NByte > 0xCF) || ($NByte == 0xC4) || ($NByte == 0xCC) )
{
if ( not eof(ImageFile) ) {read(ImageFile, $N1stByte, 1)} # 1st length byte
if ( not eof(ImageFile) )
{
read(ImageFile, $N2ndByte, 1); # 2nd length byte
my $NLength = ord($N1stByte) * 256 + ord($N2ndByte); # calculate fragment length
if ( $NLength >= 2 ) # must be at least 2 bytes
{
seek(ImageFile, $NLength - 2, 1); # seek past this fragments data
$NError = 0; # (ignore 2 bytes already read)
}
}
}
else
{
if ( not eof(ImageFile) ) {read(ImageFile, $N1stByte, 1)} # 1st length byte
if ( not eof(ImageFile) ) {read(ImageFile, $N2ndByte, 1)} # 2nd length byte
if ( not eof(ImageFile) ) {read(ImageFile, $NNextByte, 1)} # Data Precision char
if ( not eof(ImageFile) ) {read(ImageFile, $N1stByte, 1)} # 1st height byte
if ( not eof(ImageFile) )
{
read(ImageFile, $N2ndByte, 1); # 2nd height byte
$NImageHeight = ord($N1stByte) * 256 + ord($N2ndByte); # image height
}
if ( not eof(ImageFile) ) {read(ImageFile, $N1stByte, 1)} # 1st width byte
if ( not eof(ImageFile) )
{
read(ImageFile, $N2ndByte, 1); # 2nd width byte
$NImageWidth = ord($N1stByte) * 256 + ord($N2ndByte); # image width
$NImageHeight = int($NImageHeight / $NorcatScale); # scale down
$NImageWidth = int($NImageWidth / $NorcatScale); # scale down
$NError = 0;
$NFoundIt = 1; # whew - that's it
}
}
}
}
}
}
}
if ( not $NError )
{
$NorcatImage = $NorcatImageStart . $NorcatImagePrefix . $NorcatRef . $NorcatImageSuffix .
'.jpg" width=' . $NImageWidth . ' height=' . $NImageHeight . $NorcatImageEnd; # image HTML
}
close ImageFile;
}
########## end of MAIN PATCH - CHECKOUT-IMAGE with scaling V1.1 #######################################
Now update the site and that's that.