Swap images and description when selecting subproducts

General ShopSite user discussion

Swap images and description when selecting subproducts

Postby extragear » Tue Jul 19, 2011 11:45 am

Greetings:

We are looking to modify one of our templates to exhibit the following behavior. When a subproduct is selected, the description and the image associated with the subproduct replaces the default standard description and image.

Note, we already have a template that swaps out the image when the subproduct is select.

See the example of it here,

http://www.extragear1.com/hjc-is-16-arkanium-snowmobile-helmet-with-electric-shield.html

Here is the associated code with the image swap out:

[-- IF Product.NumSubproducts 0 --]
[-- ELSE --]
<?PHP

$q = "
SELECT ss_moreinfoimage1, ss_moreinfoimage2, ss_moreinfoimage3, ss_moreinfoimage4, ss_moreinfoimage5, ss_productfield21, p.ss_productsid
FROM ss_subproducts s
LEFT JOIN ss_products p ON s.ss_childid=p.ss_productsid
WHERE s.ss_productsid = '[-- Product.RecordNumber --]'
";
$r = mysql_query($q);

if ( mysql_num_rows($r) ) {

echo "var imageData = new Array();\n";
while ( $row = mysql_fetch_array($r) ) {

$breakUpCaptions = explode("\n",trim($row['ss_productfield21']));
$imageArray = array();
for ( $i=0; $i<5; $i++ ) {
$key = $i+1;
$caption = trim($breakUpCaptions[$i]);
$src = $row['ss_moreinfoimage'.$key];
if ( $src != "none" ) {
$caption = ( $caption!= "" ) ? htmlspecialchars(trim($breakUpCaptions[$i]),ENT_QUOTES): "";
$imageArray[] = "new Array('$src','$caption')";
}
}
if ( count($imageArray) ) {
echo "imageData[$row[ss_productsid]] = new Array(";
echo implode(",",$imageArray);
echo ");\n";
}

}

}

?>
[-- END_IF --]

I am assuming the swap out code for the description would be similar. Perhaps referencing the product extra fields or the description field of the subproduct.

Anyone have any suggestions concerning modifying the code to achieve this? If you're a designer and are interested in picking up a little work, feel free to PM with expected cost and timeline.

Thanks

Tim

Belden Motosport
extragear
 
Posts: 169
Joined: Mon Apr 02, 2007 10:53 am
Location: Binghamton, NY

Return to User Forum

Who is online

Users browsing this forum: No registered users and 19 guests