I am stumbling through the process of creating a very simple payment system as every one I've looked at is way to complex for my needs. So far I've manged to build a custom table and the component requirements for it using Bob's Custom Table guide. That seems to be working. I've spent hours searching the forums, reading Bob's Snippet FAQ's and trying numerous combinations.
I have a page that uses the following chunk and snippet to read from the db table and write values to a table on the page with a submit button.
<table id="prices">
<td class="item_name" width="160">[[+Size]] [[+Format]] Print</td>
<td class="item_price" width="40"><strong>$[[+Price]]</strong></td>
<td class="buy_button" width="120">
<form action="[[!getMYpid? &IDprint=`[[+PriceID]]`]]" method="post" >
<input type="image" src="assets/gfx/Add2Cart.png" alt="Click to submit"/>
</form>
</table>
The button calls the snippet getMYpid to open a new page (id 11) and pass the PrintID for another snippet to use. The idea is to read the data from the custom table to verify that the customer has chosen the correct image and size etc, and that the price has not been manipulated.
$PrintID = $scriptProperties['IDprint'];
$_SESSION['IDprint'] = $PrintID;
$webLink = "http://localhost/modx/index.php?id=11";
# $webLink = "http://localhost/modx/index.php?id=11" .$PrintID;
return $webLink;
I know the getMYpid snippet correctly transfers the value because of what the commented line produces when used. However, the next snippet either does not read the $_SESSION['IDprint'] value, or there are other errors in the snippet.
<?php
$path = MODX_CORE_PATH . 'components/Prints/';
$result = $modx->addPackage('Prints',$path .
'model/','rg_');
# get Price etc from 'rg_Prints' table
#
$PrintID = "0"; // clear the value
# $PrintID = $_POST['IDprint'];
$PrintID = $_SESSION['IDprint'];
return $PrintID;
$sortingcriteria = 'Size';
$filter1 = $PrintID;
$s = $modx->newQuery('Prints');
$s->sortby($sortingcriteria,'ASC');
$s->where(array(
'PriceID' => $filter1
));
$prints = $modx->getCollection('Prints',$s);
foreach ($prints as $photoprint) {
$fields = $photoprint->toArray();
$output = $output .$modx->getChunk('ShopItems', $fields);
}
return $output;
Finally the chunk ShopItems is called on the processing page (id 11)
<table>
<td>[[+Size]] [[+Format]] width print on [[+Medium]]</td>
<td><h3>Price: <strong>AU$[[+Price]].00</strong></h3></td>
</tr></table>
As you can probably tell from my code, I'm very inexperienced with php and mysql. Any help would be much appreciated. Hopefully it's something simple.
Thanks
Rob