unset($_SESSION['photoshop']['cart']); } pagefooter(); ob_end_flush(); exit; // we're done here } else { //something went wrong } } else { //show the cart contents and price, submit button echo "<form action='{$CONFIG['photo_shop_paypal_ssl_adress']}?file=photo_shop/photo_shop_checkout' method='post'>"; photoshop_prep_data($shop_array_cd, $shop_array_photos); echo photoshop_create_table($shop_array_photos, 'photo', 'html'); echo photoshop_create_table($shop_array_cd, 'cd', 'html'); echo photoshop_format_price($cd_price, $cd_counter, '', 'html'); echo <<<EOT <tr> <td align="left" class="tablef" colspan="7"> <table border="0" cellspacing="0" cellpadding="0" width="100%"> <tr> <td width="100%" align="center"> <input type="hidden" name="order" value="confirmed" /> <input type="submit" class="button" name="apply" value="{$lang_photoshop['send_order']}" /> </td> </tr> </table> </td> </tr> EOT; }
function photoshop_create_cart_form($box) { global $SHOP_CONFIG, $CONFIG, $THEME_DIR, $lang_photoshop; $error = ''; $tot_price = 0; $cd_counter = 0; $photo_counter = 0; $photo_price = 0; $cd_price = 0; $link = $_SERVER['PHP_SELF'] . '?file=photo_shop/photo_shop_cart'; foreach ($_SESSION['photoshop']['cart'] as $key => $temp) { //foreach //to make it better readable $item_id = isset($_SESSION['photoshop']['cart'][$key]['id']) ? $_SESSION['photoshop']['cart'][$key]['id'] : ''; $pid = isset($_SESSION['photoshop']['cart'][$key]['pid']) ? $_SESSION['photoshop']['cart'][$key]['pid'] : ''; $amount = isset($_SESSION['photoshop']['cart'][$key]['amount']) ? $_SESSION['photoshop']['cart'][$key]['amount'] : ''; //get the thumb URL $select_columns = 'filepath, filename, url_prefix, filesize, pwidth, pheight, ctime, title, aid'; $result = cpg_db_query("SELECT {$select_columns} from {$CONFIG['TABLE_PICTURES']} WHERE pid='{$pid}' LIMIT 1"); $row = mysql_fetch_array($result); //get price and name $price = $SHOP_CONFIG[$item_id]['price']; $name = $SHOP_CONFIG[$item_id]['name']; //price override $results = cpg_db_query("SELECT * FROM {$CONFIG['TABLE_SHOP_PRICES']} WHERE aid={$row['aid']}"); while ($temp_data = mysql_fetch_array($results)) { if ($temp_data['gid'] == $SHOP_CONFIG[$item_id]['id']) { $price = $temp_data['price']; } } mysql_free_result($results); //html resize thumb if ($CONFIG['enable_mini_thumbs'] == '1') { // if you use the modpack and have enabled mini thumbs -> these get used instead of html resized thumbs $thumb_url = get_pic_url($row, 'mini'); $destWidth = $CONFIG['mini_thumb_width']; $destHeight = $CONFIG['mini_thumb_height']; } else { $thumb_url = get_pic_url($row, 'thumb'); $new_size = 60; $ratio = max($row['pwidth'], $row['pheight']) / $new_size; $ratio = max($ratio, 1.0); $destWidth = (int) ($row['pwidth'] / $ratio); $destHeight = (int) ($row['pheight'] / $ratio); } if ($box == "photo" and isset($name)) { // it's a photo //here we check if the price is set to -1 (that's a free item, and we set price for display reasons back to 0.00) //do the same in cart and calc total an in function item_price, pricelist, photoshop_add_data if ($price == -1) { $price = "0.00"; } $photo_price += $amount * $price; $photo_counter += $amount; echo <<<EOT \t\t\t<tr> \t\t\t\t<td width="13%"><a href="displayimage.php?pos=-{$pid}"><img class="image" src="{$thumb_url}" width="{$destWidth}" height="{$destHeight}" alt="" /></a></td> \t\t\t\t<td align="left" valign="top" width="30%"> \t\t\t\t\t<table style="font-size:10px"> \t\t\t\t\t\t<tr><td>{$lang_photoshop['title']}</td><td>{$row['title']}</td></tr> \t\t\t\t\t\t<tr><td>{$lang_photoshop['filename']}</td><td>{$row['filename']}</td></tr> \t\t\t\t\t\t<tr><td>{$lang_photoshop['size']}</td><td>{$row['pwidth']} x {$row['pheight']}</td></tr> \t\t\t\t\t</table> \t\t\t\t</td> \t\t\t\t<td align="left" width="15%">{$name}</td> \t\t\t\t<td align="left" width="15%">{$lang_photoshop['amount']} \t\t\t\t\t\t<input type="hidden" name="item_id[]" value="{$key}" /> \t\t\t\t\t \t<input type="text" class="textinput" maxlength="5" style="width: 20px" name="count{$key}" value="{$amount}"/> \t\t\t\t</td> \t\t\t\t<td align="left" width="20%"><span style="float:right">{$price} {$CONFIG['photo_shop_currency']} {$lang_photoshop['each']}</span></td> \t\t\t\t<td width="7%" align="center"> <a href="{$link}&event=delete&item={$key}&box=photo"> <img src="{$THEME_DIR}images/delete_small.gif" border="0" alt="" /> </a> \t\t\t\t</td> \t\t\t</tr> EOT; } elseif ($box == "cd" and isset($name)) { //we're viewing the cd box, but there are also print photos, lets calculate its price too $photo_price += $amount * $price; $photo_counter += $amount; } elseif ($box == "cd" and !isset($name)) { ++$cd_counter; // += $amount; echo <<<EOT \t\t\t<tr> \t\t\t\t<td width="13%"><a href="displayimage.php?pos=-{$pid}"><img class="image" src="{$thumb_url}" width="{$destWidth}" height="{$destHeight}" alt="" /></a></td> \t\t\t\t<td align="left" valign="top" width="30%"> \t\t\t\t\t<table style="font-size:10px"> \t\t\t\t\t\t<tr><td>{$lang_photoshop['title']}</td><td>{$row['title']}</td></tr> \t\t\t\t\t\t<tr><td>{$lang_photoshop['filename']}</td><td>{$row['filename']}</td></tr> \t\t\t\t\t\t<tr><td>{$lang_photoshop['size']}</td><td>{$row['pwidth']} x {$row['pheight']}</td></tr> \t\t\t\t\t</table> \t\t\t\t</td> \t\t\t\t<td align="left" width="15%"> </td> \t\t\t\t<td align="left" width="15%"> </td> \t\t\t\t<td align="left" width="20%"> </td> \t\t\t\t<td width="7%" align="center"> <a href="{$link}&event=delete&item={$key}&box={$box}"> <img src="{$THEME_DIR}images/delete_small.gif" border="0" alt="" /> </a> \t\t\t\t</td> \t\t\t</tr> EOT; } elseif ($box == "photo" and !isset($name)) { //viewing print photos, but that's for cd ++$cd_counter; // += $amount; } } //foreach if ($cd_counter > 0) { //if we have an item added to cd $pricelist = array(); foreach ($SHOP_CONFIG as $key => $value) { //foreach if ($value['type'] == "cd") { $pricelist[$key] = $value['max_items']; } } arsort($pricelist); foreach ($pricelist as $key => $val) { if ($val >= $cd_counter) { $pointer = $key; $check = true; //echo "$key - $val<br />"; } } $error = ''; $cd_price = $SHOP_CONFIG[$pointer]['price']; if (!$check == true) { $error = "<font color=\"red\">" . $lang_photoshop['to_many_pics'] . "</font> <br />"; $cd_price = ''; } } else { $cd_price = ''; } //end if we have an item added to cd if ($box == "photo" and $photo_counter < 1) { //uncomment, then the cart print refreshes to cd if print is empty photoshop_refresh($_SERVER['PHP_SELF'] . '?file=photo_shop/photo_shop_cart&box=cd'); } //sort($pricelist); if ($box == "cd" and $cd_counter > 0) { $to_go = $SHOP_CONFIG[$pointer]['max_items'] - $cd_counter; if ($to_go > 0) { $to_go = sprintf($lang_photoshop['to_go'], $to_go); } elseif ($to_go == 0) { $to_go = sprintf($lang_photoshop['to_go_full'], $to_go); } elseif ($cd_counter - $pricelist[0]['max_items'] > 0) { $to_go = sprintf($lang_photoshop['to_go_remove'], $cd_counter - $pricelist[count($pricelist) - 1]['max_items']); } echo <<<EOT \t\t\t<tr> \t\t\t\t<td align="right" colspan="6"> \t\t\t\t\t<hr size="1" /> \t\t\t\t\t{$to_go} \t\t\t\t</td> \t\t\t</tr> EOT; } $counter['cd'] = $cd_counter; $counter['photo'] = $photo_counter; $price_t[0] = $photo_price; $price_t[1] = $cd_price; echo photoshop_format_price($price_t, $counter, $error, 'html'); }