Re: [Jason] Multi records
Here you go! I took out everything that didn't apply to clean it up...
Also when I select a qty to add to cart it only adds 1 even if I select 5. So not sure why that is either...
<?php header('Content-type: text/html; charset=utf-8'); ?>
<?php
// load viewer library
$libraryPath = 'lib/viewer_functions.php';
$dirsToCheck = array('...');
foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }}
if (!function_exists('getRecords')) { die("Couldn't load viewer library, check filepath in sourcecode."); }
list($north_americaRecords, $north_americaMetaData) = getRecords(array(
'tableName' => 'north_america',
'where' => whereRecordNumberInUrl(1),
'limit' => '1',
));
$north_americaRecord = @$north_americaRecords[0]; // get first record
// load records from 'products_na'
list($products_naRecords, $products_naMetaData) = getRecords(array(
'tableName' => 'products_na',
'loadUploads' => true,
'allowSearch' => false,
));
// error checking
$errorsAndAlerts = alert();
if (@$CURRENT_USER) {
$errorsAndAlerts = "You are already logged in!";
}
// Tally cart!
list($grandTotal, $subTotal, $extraLineItems, $talliedCartItems) = sc_tallyCart();
?>
<!-- _________________________ Start Content _________________________ -->
<div id="content">
<div id="producerDB" class="clearfix">
<div id="leftProducer">
<?php foreach ($north_americaRecord['picture'] as $upload): ?>
<?php if ($upload['isImage']): ?>
<img src="<?php echo $upload['urlPath'] ?>" width="<?php echo $upload['width'] ?>" height="<?php echo $upload['height'] ?>" alt='' /><br/>
<br/>
<?php endif ?>
<?php endforeach ?>
<?php if(!$north_americaRecord['picture']): ?>
<img src="images/default-product-image.jpg" alt="" />
<?php endif ?>
</div>
<!-- End selections -->
<div id="rightProducer">
<h2><img src="images/<?php echo $north_americaRecord['product'] ?>_icon.png" align="absmiddle"/><?php echo $north_americaRecord['name'] ?></h2>
<p><?php echo $north_americaRecord['description'] ?></p>
<?php if ($CURRENT_USER): ?>
<table width="523" border="1" bordercolor="#CCCCCC" cellspacing="0" cellpadding="4">
<tr>
<td width="174"><b>Product Name</b></td>
<td width="73"><b>Price</b></td>
<td width="73"><b>In Stock</b></td>
<td width="161"><b></b></td>
</tr>
<?php foreach ($products_naRecords as $record): ?>
<tr>
<td>
<?php echo htmlencode($record['name']) ?><br/>
(Style: <?php echo htmlencode($record['style']) ?>)<br/>
Pack Size: <?php echo htmlencode($record['pack_size']) ?><br/>
</td>
<td><?php echo htmlencode($record['price']) ?></td>
<td><?php echo htmlencode($record['quantity']) ?></td>
<td>
<!-- add to cart -->
<?php
$formName = "addform" . $record['num'];
$cartItems = array(
array(
'name' => $record['name'],
'unitPrice' => $record['price'],
'recordNum' => $record['num'],
'tableOrTag' => 'products_na',
'quantity=' => '_sc_quantity',
),
//array('name' => 'Color: Blue', 'OPTION' => TRUE),
//array('name' => 'Region: North', 'OPTION' => TRUE),
//array('name' => 'Size: Xl', 'OPTION' => TRUE),
);
?>
<form method="post" name="<?php echo $formName ?>" action="?">
<input type="hidden" name="_sc_action" value="add">
<input type="hidden" name="_sc_nextUrl" value="?">
<?php sc_createAddFormData($cartItems); ?>
<input type="text2" name="_sc_quantity" size="5" maxlength="5" value="0" /><br/>
<a href="#" title="Add to Cart" class="addToCart" onclick="document.forms.<?php echo $formName ?>.submit(); return false;">Add to Cart</a><br />
</form>
<!-- /add to cart -->
</td>
</tr>
<?php endforeach ?>
</table>
<?php endif ?>
<p>
<?php if (!$north_americaRecord): ?>
No record found!<br/><br/>
<?php endif ?>
</p>
</div>
</div><!-- End content -->
</div>
<!-- _________________________ Finish Content _________________________ -->
</body>
</html>